Game Center best practices (achievements using Unity Social API)

I am working on adding Game Center achievements in my game using Unity’s Social API and had a few questions about best practices.

I have achievements “working”, but it doesn’t seem quite right how I currently have set up. I’m hoping someone here that has used the API can help me out!

Here are my steps:

  1. Authenticate user (Social.localUser.Authenticate()
  2. After user is authenticated, load Achievements (Social.LoadAchievements()). NOTE: Any/all achievements that have 0 progress are NOT loaded. So the first time they are loaded, the list will be empty.
  3. Cache results that are loaded in so I can check them throughout game to report progress.
  4. After reporting progress on an achievement, go back to #2. NOTE: After successfully adding progress, the LoadAchievements USUALLY still shows 0 items in the achievements list. It must take some time?

Here are my main problems I would like to solve.
A) After I report progress, should I update my own cached list to keep track of progress internally instead of trying to LoadAchievements immediately afterwards? (considering sometimes they don’t get updated right away after the load).
B) If caching achievements is the way to go, then what do I do if there are 0 achievements loaded because they have 0 progress and I want to update their progress? Do I send the progress using Social, then create my own 1st entry into my own cached list and use that?

It all just seems very messy so it would be great to see how other people have implemented this. It shouldn’t be this complicated, so I’m hoping I’m just missing something.

I appreciate you taking the time to read my post, thanks in advance for any help you can give!

2 Likes

Just something to add…through years I found the Process Authenticated callback un-reliable so I’d have a fallback co-routine polling Social.localUser.authenticated

Thanks for the tip @sfjohansson much appreciated!

REWORDING: Is step #3 necessary? Do I need to cache the achievements, or can I just call ReportProgress on an already completed achievement without worry?

I realized my last reply was a bit confusing, so I reworded it:

Is step #3 necessary? Do I need to cache the achievements, or can I just call ReportProgress on an already completed achievement without worry?