Fabio
Fabio

Reputation: 1973

GameCenter iOS leaderboard identifier

this is my code to get the default leaderboard in game center but return a nil value.

and i have this info in the iTunes connect what can i do? thanks

This image is from iTunes Connect

This image is from iTunes Connect

This is from Xcode This is from Xcode

This is from device This is from device

and the code to obtain the default leaderboard

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
        if (viewController != nil) {
            [self presentViewController:viewController animated:YES completion:nil];
        }
        else{
            if ([GKLocalPlayer localPlayer].authenticated) {
                _gameCenterEnabled = YES;

                [[GKLocalPlayer localPlayer]loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString * _Nullable leaderboardIdentifier, NSError * _Nullable error) {


                    if (error != nil) {
                        NSLog(@"%@",[error localizedDescription]);
                    }else{

                        _leaderboardIdentifier = leaderboardIdentifier; // **This contains nil value**

                    }

                }];
            }else{

                _gameCenterEnabled=NO;
            }
        }

    };

Upvotes: 0

Views: 322

Answers (2)

Fabio
Fabio

Reputation: 1973

I solve this strange problem creating a new leaderboard and create a new version of my application for example 1.1 and this works for me.

Thanks for your answer crashoverride777

Upvotes: 0

crashoverride777
crashoverride777

Reputation: 10674

You code looks fine. Did you try signing out and back into Game Center on your device? I have this happening to me a few times in sandbox mode as well and a signing out and back in usually fixes it.

Upvotes: 1

Related Questions