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 !
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).
}
}];