Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When should it init GameCenterManager? #30

Open
caoer opened this issue Nov 7, 2014 · 1 comment
Open

When should it init GameCenterManager? #30

caoer opened this issue Nov 7, 2014 · 1 comment

Comments

@caoer
Copy link

caoer commented Nov 7, 2014

I first try to call

[[GameCenterManager sharedManager] setupManager];
[[GameCenterManager sharedManager] setDelegate:self];

when the app launches. However, the result comes from [self checkGameCenterAvailability] is not correct. Because of the asyn call in localPlayer.authenticateHandler.
I think this will make following code in init method not really useful. Because if GameCenterManager is init when app starts, gameCenterAvailable will always be NO. The essential syncGameCenter call is not called.

        if (gameCenterAvailable) {
            // Set GameCenter as available
            [self setIsGameCenterAvailable:YES];

            if (![[NSUserDefaults standardUserDefaults] boolForKey:[@"scoresSynced" stringByAppendingString:[self localPlayerId]]]
                || ![[NSUserDefaults standardUserDefaults] boolForKey:[@"achievementsSynced" stringByAppendingString:[self localPlayerId]]])
                [self syncGameCenter];
            else
                [self reportSavedScoresAndAchievements];
        }

I've put a temporary fix as following, everything works fine.

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [[GameCenterManager sharedManager] setupManager];
            [[GameCenterManager sharedManager] setDelegate:self];
        });

I think checkGameCenterAvailability might be refactor to use completionHandler ?

Sam-Spencer pushed a commit that referenced this issue Jan 17, 2015
Fixed some issues on Mac OS X 10.10. Fixes #31. Fixes #14. The
interface has also been updated for Yosemite. However, there are still
problems with initialization as reported in issue #30.
@Volodymyr-13
Copy link

Volodymyr-13 commented Aug 23, 2016

Hello,

I've the same issue with latest commit gameCenterAvailable will always be NO and I always see in a log: "scoresSynced not setup" and "achievementsSynced not setup". Why is that? However, after a second I see standard GC banner and afterward method: [[GameCenterManager sharedManager] saveAndReportScore:
works well and my scores sent to GC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants