native.getSync() returns error

Hello guys,

I tried to implement iCloud backup in my app, but without success.

The code I’, using is the following:

errStr = native.showAlert( "Warning", "iCloud error", { "OK" } ) local results, errStr = native.getSync( "coinfile.txt", "myTable.json", "redcoinfile.txt", "scorefile.txt", { key = "iCloudBackup" } ) 

But, if I delete and reinstall my app, instead of getting the content of my iCloud backup, I get the native popup

containing the error “Warning, iCloud error”.

I have enabled iCloud in my app provisioning profile.

If I go to settings --> iCloud --> storage --> Manage Storage --> my Device 

I can see that my apps settings have been stored on iCloud

Is there something else that I have to set up in order to have iCloud working in my app?

Thanks and best regards.

Can you provide more data?  What version of Corona SDK are you using? Are there any error messages in the device’s console log?

Now my understanding is by default everything in system.DocumentsDirectory gets backed up automatically. You need to use the native.setSync() to mark files to not backup.

In addition, I think you’re using the API incorrectly.  Please review:  https://docs.coronalabs.com/api/library/native/getSync.html

First you’re saving a value in errStr from native.showAlert(). This won’t do much. Also you’re showing the alert before you get the sync values.  Next you can only check one filename at a time. You might want your alert to show the value of errString in your native.showAlert().

But your biggest problem is you can’t check multiple files at once.

Rob

Can you provide more data?  What version of Corona SDK are you using? Are there any error messages in the device’s console log?

Now my understanding is by default everything in system.DocumentsDirectory gets backed up automatically. You need to use the native.setSync() to mark files to not backup.

In addition, I think you’re using the API incorrectly.  Please review:  https://docs.coronalabs.com/api/library/native/getSync.html

First you’re saving a value in errStr from native.showAlert(). This won’t do much. Also you’re showing the alert before you get the sync values.  Next you can only check one filename at a time. You might want your alert to show the value of errString in your native.showAlert().

But your biggest problem is you can’t check multiple files at once.

Rob

Does anyone know if the setSync function will handle folders as well as files. In the documentation it just says the first argument should be a filename. But I have an images folder that I want to completely exclude from iCloud backups. The folder ‘images’ is previously created in my documents directory, can I do the following … ?
 

native.setSync( 'images', { iCloudBackup = false } )

I tried it and the output results were value = true and errStr = nil which is promising, but I wanted to make sure because I guess there’s no real way of testing this until you publish and apple rejects your app.

Did You found out if folders are managed as well? This is really important information for me.

Does anyone know if the setSync function will handle folders as well as files. In the documentation it just says the first argument should be a filename. But I have an images folder that I want to completely exclude from iCloud backups. The folder ‘images’ is previously created in my documents directory, can I do the following … ?
 

native.setSync( 'images', { iCloudBackup = false } )

I tried it and the output results were value = true and errStr = nil which is promising, but I wanted to make sure because I guess there’s no real way of testing this until you publish and apple rejects your app.

Did You found out if folders are managed as well? This is really important information for me.