game center save game data

Error Domain=GKErrorDomain Code=27 "The requested operation could not be completed because you are not signed in to iCloud" UserInfo=0x1889f160 {NSLocalizedDescription=The requested operation could not be completed because you are not signed in to iCloud}


I'm testing it on my iPhone (iOS 12.11) logged to Game Center, to iCloud, I've got iCloud Drive turned on, but saving doesn't work. I even set up a new test account, but with the same result.what can I do?

Replies

What do you mean by 1) "logged to Game Center" and "to iCloud" and "saving"? Try to be a bit more precise.


It sounds like the user is trying to save something to their iCloud account and the device is not signed into their iCloud account.

When I tested it on the real machine, the local user logged in successfully. When I used the method of savegamedata to store the user data, Xcode told me that iCloud cloud disk was wrong. This is the error log. This is what I use code

[[GKLocalPlayer localPlayer] saveGameData: serializedData withName: @ "SaveName" completionHandler: ^ (GKSavedGame * savedGame, NSError * error) {

If (savedGame! = nil) {

NSLog(@player data saved to GameCenter: %@", savedGame);

} else {

NSLog(@player data NOT saved to GameCenter, error: %@", error.description);

}

}];

According to:


https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/GameKit_Guide/SavedGames/SavedGames.html#//apple_ref/doc/uid/TP40008304-CH19-SW1


saved games are saved to the user's iCloud Account, not the Game Center. So the system needs to know the user's iCloud Account. In your case, the system believes that the user is not logged into an iCloud Account. What iCloud Account is displayed on the Settings App on the device? Is that the same username as the local player?

My iCloud account is the same as my Game Center account, but the error still appears. Did I ignore the parameter devicename? Can you give me a sample code? thank you