Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save game data into iCloud via GameKit

I'm trying to save game's data to iCloud via next code:

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer saveGameData:[NSData dataWithBytes:rawData->data() length:rawData->size()]
                 withName:[NSString stringWithUTF8String:fileName.c_str()]
        completionHandler:^(GKSavedGame *savedGame, NSError *error) {
            if (error == nil) {
                DebugLog(@"Snapshot successfully saved");
            } else {
                DebugLog(@"saveSnapshot error: %@", error.description);
            }
        }];

But getting error message: The requested operation could not be completed because you are not signed in to iCloud

I've tried to do this in iOS Simulator and on device but didn't succeed.
And tried to use test apple ID, dev apple ID, new apple ID, but didn't succeed too.
User is logged in to iCloud in iOS Settings and logged in to Game Center.

Any suggestions?

like image 713
Mumreg Avatar asked Dec 03 '14 13:12

Mumreg


People also ask

Can I save game progress on iCloud?

iCloud and Google Play will back up your game as you play. To save your progress, log in to Google Play (on Android devices) or iCloud, (on Apple devices) play the game for some time to ensure your progress is saved to that service.

How do I save games to the cloud iOS?

Under the Settings menu, go to iCloud, then select Documents and Data. Make sure it's turned to "ON". Under the Documents and Data menu, select on (or green) for your desired game and you should be good to go.

How do I backup my game data on my Iphone?

Answer: A: Yes, go to Settings > Name > iCloud > see if the game(s) is/are listed under Apps Using iCloud. If not, go to Settings > Name > iCloud > Manage Storage > Backups > device you're on > see if the game(s) is/are listed under Choose Data To Back Up and turn on.

Does Apple Game Center save game data?

You can use iCloud and Game Center to keep your progress, high scores, and game saves up-to-date across your devices. If you're signed in to the same iCloud and Game Center accounts and download Apple Arcade games from the App Store on all of your devices, you can access your game saves and progress on all of them.


1 Answers

I had a similar issue. After I signed in with my iCloud account on my device's settings, the exact same error was still showing up, and it only stopped when I enabled the iCloud Drive for my account, otherwise it will never work.

So, it looks like the user must be using iCloud Drive, otherwise GKSavedGame will never work. Apple docs never mention that as far as I'm aware.

like image 61
user642252 Avatar answered Oct 09 '22 12:10

user642252