ios - Is it possible to trigger Game Centre Login multiple times in a single session? - Stack Overflow

I am able to trigger game center login successfully once using the below code.However, if when presen

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信