Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Game Center achievement unlocking multiple times

I set up an achievement for passing the first level of my game and it works but when i replay the level and pass it it shows the notification banner again, how can i prevent this from happening?

like image 720
matt saravitz Avatar asked Aug 01 '12 20:08

matt saravitz


1 Answers

Use this method to submit the achievement:

-(void) reportAchievementWithID:(NSString*) achievementID {

    [GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {

        if(error) NSLog(@"error reporting ach");

        for (GKAchievement *ach in achievements) {
            if([ach.identifier isEqualToString:achievementID]) { //already submitted
                return ;
            }
        }

        GKAchievement *achievementToSend = [[GKAchievement alloc] initWithIdentifier:achievementID];
        achievementToSend.percentComplete = 100;
        achievementToSend.showsCompletionBanner = YES;
        [achievementToSend reportAchievementWithCompletionHandler:NULL];

    }];

}
like image 94
Kaan Dedeoglu Avatar answered Oct 20 '22 17:10

Kaan Dedeoglu