I am able to trigger game center login successfully once using the below code. However, if when presented with the option to login, I hit the cancel button, if the app again calls setAuthenticateHandler
, no second login occurs. Is there another way to trigger login, or are we limited to 1 attempt per game session?
// First check if the user is already logged in.
if ([[GKLocalPlayer localPlayer] isAuthenticated])
{
// Don't login if the user is already logged in.
return;
}
auto authenticateHandler = ^(UIViewController* gcViewController, NSError* error)
{
if (gcViewController != nil)
{
// We need to show some UI to complete the GC login.
UIWindow *window = [UIApplication sharedApplication].delegate.window;
UIViewController *rootViewController = window.rootViewController;
[rootViewController presentViewController:gcViewController animated:TRUE completion:nil];
}
else if (error != nil)
{
// error, log it
}
else
{
if ([[GKLocalPlayer localPlayer] isAuthenticated])
{
// login succeeded
}
else
{
// no login performed
}
}
};
[[GKLocalPlayer localPlayer] setAuthenticateHandler: authenticateHandler];
I also tried to setAuthenticateHandler
to a different dummy function, then back to the valid handler above, to no success.
I didn't see any information about this in the documentation.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744622641a4584440.html
评论列表(0条)