iOS iCloud SaveGame

Anything libgdx related goes here!

iOS iCloud SaveGame

Postby TruckerJoe » Tue Nov 13, 2018 7:03 am

Hi Everyone,

I have a app called Trucker Joe on Android, and now on iOS Plattform.
I have problems to include cloud savegame for iOS.
On the Android System I use Google Games for it, and it works well.
Is here anyone who has cloud saving for iOS implemented, and can show me some code, or a link to a good tutorial?

Thanks for your help...
TruckerJoe
 
Posts: 4
Joined: Tue Nov 13, 2018 6:52 am

Re: iOS iCloud SaveGame

Postby Androphin » Tue Nov 13, 2018 8:46 am

What problems do you run into?
Androphin
 
Posts: 34
Joined: Sun Aug 07, 2016 9:30 pm

Re: iOS iCloud SaveGame

Postby TruckerJoe » Tue Nov 13, 2018 9:33 am

I tried to use the saveGameData method from GKLocalPlayer:
Code: Select all
NSData data = new NSData(bytes);
        GKLocalPlayer localPlayer = new GKLocalPlayer();
        localPlayer.saveGameData(data, "trucker.joe",

but I don´t know how to make the 3rd parameter @Block VoidBlock2<GKSavedGame, NSError> handler
TruckerJoe
 
Posts: 4
Joined: Tue Nov 13, 2018 6:52 am

Re: iOS iCloud SaveGame

Postby evilentity » Tue Nov 13, 2018 5:16 pm

Pretty sure thats now how you are supposed to get the local player. You might need to make sure it is initialized as well. You ide should be able to autocomplite the void block...
Code: Select all
localPlayer = GKLocalPlayer.getLocalPlayer();
localPlayer.setAuthenticateHandler(new VoidBlock2<UIViewController, NSError>() {
    @Override public void invoke (UIViewController uiViewController, NSError nsError) {
        initialized = true;
        // check if is signed in maybe or whatever
    }
});
// later in some other method
if (initialized) {
    NSData data = new NSData();
    localPlayer.saveGameData(data, "key", new VoidBlock2<GKSavedGame, NSError>() {
        @Override public void invoke (GKSavedGame gkSavedGame, NSError nsError) {
             // check if it worked etc
        }
    });
}
Looking for a freelancer? PM me!
evilentity
 
Posts: 4555
Joined: Wed Aug 24, 2011 11:37 am

Re: iOS iCloud SaveGame

Postby TruckerJoe » Wed Nov 14, 2018 1:44 pm

Thank you a lot!!
I am much further now!
TruckerJoe
 
Posts: 4
Joined: Tue Nov 13, 2018 6:52 am

Re: iOS iCloud SaveGame

Postby TruckerJoe » Thu Nov 15, 2018 10:27 am

I get the localplayer authenticated now, but when I make localPlayer.saveGameData I got this error:

Code=27"Der angeforderte Vorgang konnte nicht abgeschlossen werden da du nicht bei iCloud angemeldet bist bzw. iCloud Drive nicht aktiviert hast"

I my device settings I see that I am connected to iCloud, but under iCloud Drive are only other apps then my.
In the apple developer setting I made an iCloud Container, and renewed the Provisioning Profiles, and downloaded them.

I my Info.plist.xml I added:

Code: Select all
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.com.sundrumdevelopment.truckerjoegdx</string>
    </array>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudDocuments</string>
    </array>
    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
        <string>iCloud.com.sundrumdevelopment.truckerjoegdx</string>
    </array>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>


Do you have any idea what I can try?
TruckerJoe
 
Posts: 4
Joined: Tue Nov 13, 2018 6:52 am


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Google [Bot], QuiIIraven and 1 guest