Hi there!
I’m facing some problems using loadAllGameData method. If I understood it correctly, loadAllGameData will trigger an onLoadGameData callback for every savefile the user have on the cloud. My problem is that I need to force synchro with one of the savefiles every time the user open the app (by design). If the save doesn’t exist, no callback will be called and the game hangs.
@yinjimmy Is there a way I can ask the plugin if a certain save exists?
Anyway, I have thinking a bit more about this… I think that all asynchronous calls must have at least a callback (maybe we can make it a programming rule xD) so it can be interesting that if no savefile exists, a noGameDataToLoad callback or something similar is called instead. What do you think about that?
Hey! @htlxyz, error null is a normal behaviour of the onLoadGameData if everything is ok, maybe you wanted to say a savedData null.
Yesterday, I had a talk with some friends that are using some Unity plugin in their game and they have a nice solution for this problem. They have a method that fetches all metadata before actually downloads any savefile. In our case I think we can have something like this:
With this method that has to callback in all cases (empty vector if something is wrong or no data is on the cloud), we can do something like this (CloudManager has a std::vector<string> _saveFilesToRead; attribute and manages all callbacks from sdkbox):
void CloudManager::load()
{
sdkbox::PluginSdkboxPlay::fetchAllSaveFiles([this](std::vector< std::string> saveFiles)
{
if(saveFiles.size() > 0)
{
for(std::string saveFile : saveFiles)
_saveFilesToRead.push_back(saveFile);
sdkbox::PluginSdkboxPlay::loadAllGameData();
}
else
{
// Do your end reading data stuff
}
});
}
Then in the callback we do this:
void CloudManager::onLoadGameData(const sdkbox::SavedGameData* savedData, const std::string& error)
{
if(error == "" && savedData->dataLength > 0)
{
// Read the saveFile stuff
}
_saveFilesToRead.erase(std::remove(_saveFilesToRead.begin(), _saveFilesToRead.end(), savedData->name), _saveFilesToRead.end());
if(_saveFilesToRead.size() == 0)
{
// Do your end reading data stuff
}
}
I think this is a nice solution and can cover the needs of everyone
hi there @htlxyz! We have recently started the iOS QA and we have found a rare issue on this library (on android seems to be working well). The steps I do to reproduce the issue:
Install the game and play until we save a file on cloud.
Uninstall the game.
Do a fresh install, when onGameDataNames is called, the names array is empty.
Close the game and reopen, names array from onGameDataNames contains the file name.
We have tested this with different devices and iOS versions and no one can retrieve the info on the first launch after a fresh install. Any ideas?
i checked our code, i figure out this, we invoke fetchSavedGamesWithCompletionHandler, but this function just return nil with no error. i guess this maybe a apple issue.
Ohhh I see… I have made a workaround, it’s nasty, but seems to work. What a shame that Apple hasn’t solved a bug (in my opinion, a critical one) reported half and a year ago…