Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Jamie West correctly noted that the problem was the changeover to authenticateHandler in iOS6, which seems to have left authenticateWithCompletionHandler: broken. Since it's been deprecated, Apple is unlikely to fix their bug.</p> <p>Here's everything that I needed. Note both the conditional to check iOS5 version (to support both 5 and 6) and the need to call up a view controller if it's sent (e.g., authenticateHandler: isn't a direct replacement to authenticateWithCompletionHandler: — you have to do some extra work).</p> <pre><code>-(void)authenticateLocalUser { if (!self.checkingLocalPlayer) { self.checkingLocalPlayer = YES; GKLocalPlayer *thisPlayer = [GKLocalPlayer localPlayer]; if (!thisPlayer.authenticated) { #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { [thisPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error) { if (viewcontroller) { [self.delegate presentViewController:viewcontroller]; } else { [self finishGameCenterAuthWithError:error]; } })]; } else { [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { [self finishGameCenterAuthWithError:error]; } ]; } } } } </code></pre> <p>The presentViewController: function simply calls up the new view controller from my top view controller (which I had to figure out by hand in my program to make all this work):</p> <pre><code>-(void)presentViewController:(UIViewController *)thisVC { [myTopVC presentModalViewController:thisVC animated:YES]; } </code></pre> <p>Unfortunately, as of iOS6, it looks like GameCenter won't try to reauth a user if that's already been canceled in the current session, so at least some of my point of reauthing when appropriate is gone. But, it's still there for iOS5 (and maybe other situations than canceling?). </p> <p>It <em>will</em> try to reauth when the app is called back up from sleep if a user has gone and done something else.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload