0

I'm wondering if there is a simple a way to retrieve the best score and the last achievement that has been unlocked for the local user in an iOS app.

Thanks for your advices !

Pierre
  • 10,593
  • 5
  • 50
  • 80

1 Answers1

0

Yes there is:

1) Best score: Create a GKLeaderBoard instance called myLeaderBoard and set the category you want (as in leader board ID) and set the timeScope property to GKLeaderboardTimeScopeAllTime

Then, GKLeaderBoard has the following:

- (void)loadScoresWithCompletionHandler:(void (^)(NSArray *scores, NSError *error))completionHandler

When the request is done, the completion handler is called and from that moment on, myLeaderBoard instance will have the following property: localPlayerScore which is the best score up to now, store it and use it as you wish :)

2) Most recent Achievement: This works in the same spirit, do the following:

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

//sort using the lastReportedDate property of GKAchievement (which is an NSDate).

}
   }];
Kaan Dedeoglu
  • 14,765
  • 5
  • 40
  • 41