0

I am having some problems trying to implement game center achievements into an iOS game. The game already has the player authentication and leaderboards setup and they are working fine. The first error I get is when using this method:

GKAchievementDescription.loadAchievementDescriptionsWithCompletionHandler 

It gives me an error which states two things:

  1. "The requested operation could not be completed due to an error communicating with the server."
  2. "App does not support achievements."

Five achievements have been added to iTunes connect so I don't no why it says it doesn't support them. The other issues are when I use this method:

GKAchievement.reportAchievements

When this is called the error in the completion handler is nil, but it returns "no bundle for bundleID: (null)". The achievement banner doesn't show and there is no achievements tab in the game centre view.

The app was recently transferred to another developer but he then wanted some extra features added to it, so I'm using a provisioning profile and developer certificate provided by him so I can test game center and in app purchases properly. It seems like the problem I'm having is relating to the transfer?

So my question is what could be the problem causing the game to 'not support achievements'?

Any help would be much appreciated, thank you.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
jm1175
  • 165
  • 10

1 Answers1

0

Your question is a bit vague, how are those two methods looking exactly in your code. Its hard to help with two lines of a function

You load code should look something like this

 /// Load achievements
func loadAchievements(){
    print("Loading submitted achievements")

    GKAchievement.loadAchievementsWithCompletionHandler( { (achievements, error:NSError?) -> Void in
       guard error == nil else {
       print("Error loading achievements progress: \(error)")
           return
       }

      guard let validAchievements = achievements else { return }
      for achievement in validAchievements {
          print("Name: \(achievement.identifier)")
          print("Percentage: \(achievement.percentComplete)")
          print("Date: \(achievement.lastReportedDate)")
          self.achievementsDict.updateValue(achievement, forKey: achievement.identifier!)
       }
   })
}

You report code should look something like this

/// Save achievement progress
func reportAchievementProgress(percent: Double, achievementID: String) {

    guard self.localPlayer.authenticated else { return }

    let achievement = self.checkAchievement(achievementID) as GKAchievement? // 
    if achievement != nil {
       achievement!.percentComplete = percent
       achievement!.showsCompletionBanner = true

       GKAchievement.reportAchievements([achievement!], withCompletionHandler: { (error:NSError?) -> Void in
          guard error == nil else {
                print(error)
                return
           }

          print("Reported achievement: \(achievementID)) to: \(percent) %")
       })
    }
}

/// Check achievement
private func checkAchievement(achievementID: String) -> GKAchievement {
    var achievement = self.achievementsDict[achievementID]
    if achievement == nil {
        print("Achievement with no previous progress, saving...")
        achievement = GKAchievement(identifier: achievementID)
        self.achievementsDict.updateValue(achievement!, forKey: achievement!.identifier!)
    }
    return achievement!
}

achievementsDict is a dictionary where you cache your achievements.

var achievementsDict = [String: GKAchievement]()

Does this help?

crashoverride777
  • 10,581
  • 2
  • 32
  • 56