Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gamecenter authentication issue

So I've updated the way I authenticate players for gamecenter and I'm still getting a crash at start up.

This is the new way I authenticate:

- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
    if (viewController != nil)
    {
        NSLog (@"user not logged in to GC");
    }
    else if ([GKLocalPlayer localPlayer].isAuthenticated)
    {
        NSLog(@"gamecenter authentication process succeeded");
    }
    else
    {
        NSLog(@"user not authenicated");
    }
};
}

Here's what is shown when it crashes:

2014-11-12 16:20:43.295 ZombieConga[7492:881764] -[GKLocalPlayerInternal name]: unrecognized       selector sent to instance 0x7974b8c0
2014-11-12 16:20:43.298 ZombieConga[7492:881764] *** Terminating app due to uncaught     exception 'NSInvalidArgumentException', reason: '-[GKLocalPlayerInternal name]: unrecognized   selector sent to instance 0x7974b8c0'
*** First throw call stack:
(
0   CoreFoundation                      0x01ef6946 __exceptionPreprocess + 182
1   libobjc.A.dylib                     0x01b8ea97 objc_exception_throw + 44
2   CoreFoundation                      0x01efe5c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3   CoreFoundation                      0x01e473e7 ___forwarding___ + 1047
4   CoreFoundation                      0x01e46fae _CF_forwarding_prep_0 + 14
5   SpriteKit                           0x01a20f82 -[SKNode isEqual:] + 124
6   Foundation                          0x015f5612 +[NSObject(NSDelayedPerforming) cancelPreviousPerformRequestsWithTarget:] + 345
7   GameCenterFoundation                0x0b1ef11e -[GKPlayer postChangeNotification] + 45
8   GameCenterFoundation                0x0b209aa8 __52-[GKDaemonProxy setLocalPlayer:authenticated:reply:]_block_invoke + 922
9   libdispatch.dylib                   0x0237a30a _dispatch_call_block_and_release + 15
10  libdispatch.dylib                   0x0239ae2f _dispatch_client_callout + 14
11  libdispatch.dylib                   0x0238190e _dispatch_main_queue_callback_4CF + 606
12  CoreFoundation                      0x01e5095e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
13  CoreFoundation                      0x01e0f760 __CFRunLoopRun + 2256
14  CoreFoundation                      0x01e0ebcb CFRunLoopRunSpecific + 443
15  CoreFoundation                      0x01e0e9fb CFRunLoopRunInMode + 123
16  GraphicsServices                    0x036dc24f GSEventRunModal + 192
17  GraphicsServices                    0x036dc08c GSEventRun + 104
18  UIKit                               0x0019f8b6 UIApplicationMain + 1526
19  ZombieConga                         0x000f898d main + 141
20  libdyld.dylib                       0x023c6ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Why is it crashing?

like image 263
user3593148 Avatar asked Nov 12 '14 22:11

user3593148


People also ask

How do you authenticate Game Center?

Game Center also checks whether you configured your game for Game Center. To authenticate the user, set the authentication handler ( authenticateHandler ) on the shared instance of GKLocalPlayer that represents the player of your game as in: GKLocalPlayer. local.

How do you fix Game Center on iPhone?

Fo the issue with Game Center, restart iPhone first. Go to Settings > Game Center > Sign out and sign back in. If it continues, try connecting to a different Wi-Fi network or try from cell network.

Is Game Center login same as Apple ID?

Check your settings on your iPhone, iPad, or iPod touch Make sure that you're signed in to Game Center with the same Apple ID that you use on your other devices. Go to Settings > Game Center to see the Apple ID that you're using with Game Center.

How do I recover my Game Center account?

Open the Game Center settings on your device (Settings → Game Center). Log in using the Apple ID and password from the Game Center account your game was bound to. Launch the game. You will be prompted to restore you game account linked with your Google account.


1 Answers

The solution for my game was quite strange (I don't understand it completely myself). By moving the call to [self authorizeLocalPlayer] until later in the lifecycle, such as when I first initialize the SKScene, rather than early in -(void)viewDidLoad, it prevented this crash.

I believe this has to do with an issue with threads, but I cannot be sure. Some changes I made to code, that seemed unrelated, having to do with multithreading caused this to break again (I had to change a call to performSelector:withObject:afterDelay: to [NSTimer scheduledTimerWith...].

Basically, this is a very hard to track down issue, that requires some messing around with. Sorry I could not be more specific :(

like image 83
erdekhayser Avatar answered Oct 04 '22 15:10

erdekhayser