GameCenter authenticate:GKErrorDomain Code=2 "The requested operation has been cancelled."
2013-05-10 10:37
591 查看
测试GameCenter的登陆authencitate,登陆方法如下:
使用GameCenter在模拟器上运行正常,在真机上第一次登陆运行就遇到了NSError错误提示:
正常情况下登陆,如果你的Apple ID默认已经登陆过,会弹出欢迎XX界面
第一次登陆,会弹出GameCenter登陆AppleID的提示框
localPlayer.authenticated值为false 表示登陆失败,但是我的AppleID已经登陆过了,正常情况下是不应该失败的
最后在stackoverflow上的一哥们的方法解决了 问题可能是由于登陆函数和模拟器上的函数绑定了。。。原因不太重要,重要的解决办法
在View加载的地方调用一下如下函数:
把你的APPID登陆进去 然后点log out 注销 再把上面的代码从程序中删除掉
再重新在真机上调试你的程序即可
解决办法参考:stackoverflow
GameCenter登陆需要注意:
1.ios6.0后需要手动设置authenticateHandler,authenticateWithCompletionHandler: 已经在6.0中丢弃不用了
2.authenticationHandler第一个参数viewController在AppleID没有登陆的时候 需要手动显示“登陆GameCenter"界面,还要需要注意暂停逻辑
当你设置了authenticationHandler并发出了验证玩家的请求。
当app进入foreground(前台)。
在登录时,例如玩家在进入游戏前没有登录,进入时会弹出登录界面,在这个界面中的任何交互都会调用authenticationHandler。
-(void) authenticateLocalPlayer { GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) { [self setLastError:error]; if (CCDirector::sharedDirector()->isPaused()) { CCDirector::sharedDirector()->resume(); } // Player already authenticated if (localPlayer.authenticated) { _gameCenterFeaturesEnabled = YES; } else if(viewController) { CCDirector::sharedDirector()->pause(); [self presentViewController:viewController]; } else { _gameCenterFeaturesEnabled = NO; } }; }
使用GameCenter在模拟器上运行正常,在真机上第一次登陆运行就遇到了NSError错误提示:
GKErrorDomain Code=2 "The requested operation has been cancelled."
正常情况下登陆,如果你的Apple ID默认已经登陆过,会弹出欢迎XX界面
第一次登陆,会弹出GameCenter登陆AppleID的提示框
localPlayer.authenticated值为false 表示登陆失败,但是我的AppleID已经登陆过了,正常情况下是不应该失败的
最后在stackoverflow上的一哥们的方法解决了 问题可能是由于登陆函数和模拟器上的函数绑定了。。。原因不太重要,重要的解决办法
在View加载的地方调用一下如下函数:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gamecenter:"]];
把你的APPID登陆进去 然后点log out 注销 再把上面的代码从程序中删除掉
再重新在真机上调试你的程序即可
解决办法参考:stackoverflow
GameCenter登陆需要注意:
1.ios6.0后需要手动设置authenticateHandler,authenticateWithCompletionHandler: 已经在6.0中丢弃不用了
2.authenticationHandler第一个参数viewController在AppleID没有登陆的时候 需要手动显示“登陆GameCenter"界面,还要需要注意暂停逻辑
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)3.这个登陆block函数在三种情况下会被调用:
当你设置了authenticationHandler并发出了验证玩家的请求。
当app进入foreground(前台)。
在登录时,例如玩家在进入游戏前没有登录,进入时会弹出登录界面,在这个界面中的任何交互都会调用authenticationHandler。
相关文章推荐
- TOMCAT "Access to the requested resource has been denied" 的解决办法
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
- Error: "The application domain in which the thread was running has been unloaded"
- Work around by " Due to heavy load, the latest workflow operation has been queued. "
- Apache "No services installed"问题的处理以及Apache提示 the requested operation has failed而无法启动
- the requested operation has failed"解决方案
- iOS:Error Domain=WebKitErrorDomain Code=101 "The operation couldn’t be completed. (WebKitErrorDomain
- iOS[问题解决] Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.
- Apache "No services installed"问题的处理以及Apache提示 the requested operation has failed而无法启动
- apache安装完成之后,start出现了"the requested operation has failed !"
- 【解决方法】Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.
- Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (k
- Source insight上修改samba共享ubuntu上内核源程序文件出现"Confirm by typing ‘yes' below"、"has been changed outside of the editor. Do you want to
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed.
- Work around by " Due to heavy load, the latest workflow operation has been queued. " 分类: Sharepoint 2015-07-08 00:19 3人阅读 评论(0) 收藏
- 进行网络出现问题Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because th
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
- "Unable to get image data from canvas because the canvas has been tainted by cross-origin data"问题产生原
- iOS xcode 7网络请求错误failure Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded