score submittion failure

我只是一个虾纸丫 提交于 2019-12-13 05:15:22

问题


I am receiving always a Failure in my cocos2d, but when I run this project in my view based application then it will give me success, and the score will easily submitted

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
    if (error ==nil) {
        NSLog(@"Success");
    } else {
        NSLog(@"Fail");
    }   
}];


GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"123"] autorelease];
myScoreValue.value =  lastScore;

[myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
    if(error != nil){
        NSLog(@"Score Submission Failed");
    } else {
        NSLog(@"Score Submitted");
    }

}];

回答1:


Have you added the GameKit framework, and also; where have you placed the code?

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){ if (error ==nil) { NSLog(@"Success"); } else { NSLog(@"Fail"); }

}];

You have to authenticate when the user starts the app, or when the viewDidLoad function is called.

I don't think I really understand what your problem is. What warnings do you geT?




回答2:


I had this error, too. I think it happens when you're logged into a regular gamecenter acct and try to autenticate with an app that needs to be sandboxed. But I'm not sure of that, that's just a guess.

What worked for me was to go and log out with the Game Center app, and then try the app again, and that will login or create a sandboxed user.

Not the most descriptive error message ever though.



来源:https://stackoverflow.com/questions/5270318/score-submittion-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!