Unable to authenticate Local Player with GameKit (Game Center) on watchOS

Viewed 406

I'm trying to integrate Game Center on a watchOS app but I'm unable to authenticate the Local Player.

Maybe I'm missing any step to allow the companion watchOS app to access Game Center as the iOS app does?

Setup

  • iOS App Deploying target for iOS 14
  • Companion watchOS App that supports running without iOS App installation, target watchOS 7
  • Game Center capability is active both on iOS and watchOS App Extension targets
  • The app is not live yet, but already on "Prepare for Submission" on App Store Connect
  • Game Center checkbox is on, on App Store Connect
  • There are a few Leaderboards already created on App Store Connect
  • iOS app is able to connect to Game Center for authenticating, submitting scores, and displaying leaderboards
  • When testing on the simulator I have an iPhone paired with a Watch. Sandbox account is authenticated on the iPhone.
  • When testing on a real device I have an iPhone paired with a Watch, real account is authenticated on the iPhone.

Already tried

On the watchOS App Extension I'm calling:

GKLocalPlayer.local.authenticateHandler = { error in

}

Which is very similar to the method used to authenthicate on iOS, and on iOS it works, even on the simulator.


When calling that method, and running on a simulator I get this log on Xcode's debug area:

[Error] _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo={NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}

and the error message received on the completion handler is:

Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo={NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}

When testing the same scenario on a real device I get the log:

[Error] _authenticateUsingAlert:Failed to authenticate player with existing credentials.Error: Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognised by Game Center." UserInfo={GKServerStatusCode=5019, NSUnderlyingError=0x11e3a6c0 {Error Domain=GKServerErrorDomain Code=5019 "status = 5019, no game matching descriptor: ios:com.myApp.test.watch.extension::0+-1" UserInfo={GKServerStatusCode=5019, NSLocalizedFailureReason=status = 5019, no game matching descriptor: ios:com.myApp.test.watch.extension::0+-1}}, NSLocalizedDescription=The requested operation could not be completed because this application is not recognised by Game Center.}

and the error from the completion handler is:

Error Domain=GKErrorDomain Code=15 "The requested operation could not be completed because this application is not recognised by Game Center." UserInfo={NSLocalizedDescription=The requested operation could not be completed because this application is not recognised by Game Center.}

Both these errors are similar to the messages you get on iOS when the app hasn't enabled Game Center on App Store Connect. As mentioned before this is not the case as on iOS works fine.

I also tried moving the app to a Game Center Group on App Store Connect, as it says this is meant to share leaderboards and achievements, but the result was the same.

2 Answers

After weeks of pulling my hair I found out (the hard way) that Game Center works on watchOS only when on a real device, and it works very limited.

You can access the local player display name but you can't submit scores.

I even tried adding the app to Game Center Groups, it didn't help.

--

PS. It will still show error messages and warnings on Xcode's console saying that user is not authenticated or that app is not recognised by Game Center, but it will work if you try to get GKLocalPlayer.local.displayName after authenticating with GKLocalPlayer.local.authenticateHandler. It also apparently will submit scores to leaderboards or at least will show no error, but the scores never get submited.

I had a similar error but it was not related to using Apple Watch OS however I had this error and it was a simple oversight as I had not put the right bundle identifier when I added the app on App Store connect so if you had something similar try checking if the bundle identifier is corresponding with your project.

Related