Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
369 views
in Technique[技术] by (71.8m points)

ios - Game Center login dialog not shown again after cancelling it for the first time (iOS7)

I have a problem with logging a user to the Game Center. I first present the login dialog right after the application finishes loading. If the user cancels the dialog, I want to give him the option to change his mind by providing a login button in my main menu. However, on iPads with iOS7, the button doesn't do anything - the Game Center dialog doesn't get shown (it works correctly on iOS6). Instead, I immediately get the error "The requested operation has been cancelled or disabled by the user." Same code is called on application launch and on the button tap. It uses the authenticateWithCompletionHandler method and basically looks like:

GKLocalPlayer* localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error)
{
    OnLogin(error);
}];

(I know the method is deprecated, but my experience with the new one has been even worse).

The interesting thing is that the GC dialog DOES appear if I move the application to the background and then bring it back to the foreground.

The issue I describe happens even after the first cancel, so I don't think it has anything to do with Game Center banning applications after 3 cancels.

Does anyone know how to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In regards to your comment, I found the Apple documentation that mentions Game Kit's policy of not asking a user to login again after they have cancelled login once.

It's in the Game Center Programming Guide under Common Tasks When Working with Players > Authenticating a Local Player on the Device. (bold type is mine)

Important: Game Kit handles opting out of Game Center across all games that support Game Center. If a player has already declined to create an account, when your game authenticates the player, it is told there is no authenticated player. The player never sees an authentication dialog. Because Game Kit handles this process across all games, your game should not include its own mechanism to disable Game Center authentication or ask a player’s permission to authenticate. Instead, your game should simply authenticate the player every time it launches and respond appropriately when authentication completes.

You can confirm this by including an NSLog in the authentication handler to show each time the handler is called and whether it succeeded or failed. Hope this helps...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...