Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving game center achievement by identifier

I have a question related to Game center achievements. Is it possible to retrieve the name/description of an achievement by its identifier? I am trying to avoid hardcoding every identifier with its corresponding name, so is there a solution that can get the name? thanks, Sami

like image 747
Sami Avatar asked Aug 04 '11 21:08

Sami


People also ask

Is Game Center connected to Apple ID?

Game Center uses the Apple ID that's linked to your iPhone or iPad by default. Since Game Center accounts are tied to Apple accounts, you may have been under the notion that you cannot use a different account unless you completely sign out of your device.

How do I find my Game Center ID?

Open your Settings Application then locate "Game Center" and tap on this. Your Game Center ID is your Apple ID. After iOS 10 there is no Game Center app, so all Game Center settings must be managed in here. For iOS 10 you can see your Game Center username in the Game Center application.

Does Game Center save your game progress?

Make sure you have connected your game to Game Center. It is the only way to save, recover and sync your progress. Your account is not saved via connecting it to Facebook.

How do I see my friends’ achievements on Game Center?

In the App Store on your Mac, click Arcade in the sidebar. Click your name in the bottom-left corner, then click Game Center Profile near the top of the window. To see your friends’ achievements, click Recently Played With. You can also see your Game Center profile, achievements, friends’ achievements, and more in the Game Center in-game dashboard.

How does Game Center know when an achievement is completed?

This method is called when the player completes an achievement. The first thing the code does is create a new achievement object to tell Game Center that the achievement has been completed. If the player completes multiple achievements for a challenge at once, create a new object for each achievement and add the achievement to an array.

How can I See which games I have earned achievements?

If you play a lot of games, it's great to be able to brag to your friends about your achievements. Of course, if you play a lot of games, you get a lot of achievements. To double check which ones you have earned, you can find them in Game Center on iOS 8. Here's how:

What is my achievement ID and how do I edit it?

Your achievement ID is a permanent setting and therefore cannot be edited at a later date. The achievement ID is used inside your game to refer to this achievement. The points that your achievement is worth. Achievements marked as Hidden remain hidden to a player on Game Center until after the first time you report progress for that achievement.


1 Answers

Of course, that's exactly why you have localization support for achievements (as well as leaderboards) inside iTunes Connect.

However, there is no way to ask Game Center about localized info for just one achievement based on it's ID. Instead, you ask for info about all achievements which gives you an array of GKAchievementDescription objects which would be best to put into a dictionary where keys are achievement IDs and then you select a proper GKAchievementDescription object from that dictionary.

NSMutableDictionary *achievementDescriptions = [[NSMutableDictionary alloc] init];
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) {
    if (error != nil) {
        NSLog(@"Error getting achievement descriptions: %@", error);
    }
    for (GKAchievementDescription *achievementDescription in descriptions) {
        [achievementDescriptions setObject:achievementDescription forKey:achievementDescription.identifier];
    }
}];

And then when you want to display info for some achievement:

GKAchievementDescription *achievementDescription = [achievementDescriptions objectForKey:currentAchievement.identifier];

This object gives you a localized title, description for when it is achieved and unachieved, as well as number of points it awards and an image you specified in iTunes Connect.

like image 145
Filip Radelic Avatar answered Oct 03 '22 14:10

Filip Radelic