SDKBoxPlay iCloud Save general questions

SDKBoxPlay iCloud Save general questions
0.0 0



A. General question on iCloud Save using SDKBoxPlay. I have tried integrating it. Seems to be working fine, but encountered issues:

(1) When calling sdkbox::PluginSdkboxPlay::loadGameData(“AAA”);, the onGameData listener gets triggered more than once with two different data. I am not sure why it’s saving two different data using 1 key. My saving code:

void MainMenuScene::savePlayerDataCloud()

rapidjson::Document d;
// Create a rapidjson array type with similar syntax to std::vector
rapidjson::Value array(rapidjson::kArrayType);
// Must pass an allocator when the object may need to allocate memory
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();

d.AddMember(rapidjson::StringRef("iHardCurrency"), egpUser->iHardCurrency, allocator);
d.AddMember(rapidjson::StringRef("iSoftCurrency"), egpUser->iSoftCurrency, allocator);
d.AddMember(rapidjson::StringRef("fXPBarProgress"), egpUser->fXPBarProgress, allocator);
StringBuffer strbuf;
Writer<StringBuffer> writer(strbuf);
//log("JsonData = %s", strbuf.GetString());
sdkbox::PluginSdkboxPlay::saveGameData("AAA", strbuf.GetString());

I basically create a JSON, and then call saveGameData(“AAA”, JSON Formatted string); Note: egpUser is just a Player data class. And then I call the savePlayerDataCloud method everytime I needed to save one of the three data (Hard Currency, Soft Currency, and the XP Progress) of the player.

UPDATE: My observation is this happens everytime I reinstall the app. Seems like calling saveGameData on a newly installed app creates a different record in the cloud with same key name… and then when calling it using loadGameData, it returns 2 or more new results depending on how many times u reinstalled the app.

void MainMenuScene::onGameData(const string & sAction, const string & sName, const string & sData, const string & sError)
if(sAction == “save”)
log(" --------------- Saving Cloud Data ---------------");
log(" Name: %s", sName.c_str());
log(" Data: %s", sData.c_str());
log(" Error: %s", sError.c_str());
else if(sAction == “load”)
log(" ---------------Loading Cloud Data---------------");
log(" Name: %s", sName.c_str());
log(" Data: %s", sData.c_str());
log(" Error: %s", sError.c_str());

    rapidjson::Document e = EGUtils::loadJsonFromString(sData.c_str());
    egpUser->iHardCurrency = e["iHardCurrency"].GetInt();
    auto lblPlayerGems = (Label *) utils::findChild(this, TAG_PLAYER_GEMS_LABEL);

    egpUser->iSoftCurrency = e["iSoftCurrency"].GetInt();
    egpUser->fXPBarProgress = e["fXPBarProgress"].GetFloat();
    auto lbLoadingBarProgress = (LoadingBar *) utils::findChild(this, TAG_XP_BAR);

My onGameData code… this one gets triggered multiple times as I’ve said depending on how many times I reinstalled the app.

My expected output:

I play game using my Apple ID with iCloud/Cloud Drive enabled
Save my data to my cloud
Uninstall the app
Install the app
Load the cloud data
Get 1 data only.
(2) I also get this Error when calling saveGameData for the first time…

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.}

But on second call, it works. I was under the impression that the iCloud save is different from the Game Center and doesn’t need any authentication. Am I right? Btw, the iCloud account I am using is not a developer account.

C. Also, do I need to setup up something in the iCloud dashboard so I can see user records? I just followed the integration manual but did not do anything after I created by iCloud containers.

Please help. Thank you.


trying to reproduce this issue, thanks for your report.


Ok, thank you.

Additional info for your investigation:

cocos2d-x 3.15
sdkbox play is
XCode 8.3.3

I’m sure I have setup the project capabilities for iCloud and added the right containers.


i tested with sdkbox-sample-sdkboxplay cpp project, but can’t reproduce.

can you try with sdkbox-sample-sdkboxplay?