Question

If I make an app in PhoneGap that uses localStorage to store key/value data, will this data be synched to other devices via iCloud? I don't need to save much data.

Was it helpful?

Solution

No, localStorage is browser based and persists through the UIWebView that Phonegap gives you to play in, it's not tied to an app.

You can write a plugin to access the documents directory to save information to iCloud with Phonegap.

Old incorrect information here. See @asgeo1's answer below.

OTHER TIPS

I disagree with @sciritai.

localStorage in iOS is just an SQLite db file that is stored somewhere on the device.

Perhaps things were different in a previous Phonegap/Cordova version, but in the current version Phonegap writes the localStorage.db file into the Documents directory for your app.

Specifically: Documents/Backups/localstorage.appdata.db

Since the Documents directory is specific for each app, it will be automatically saved to iCloud.

I can confirm this when I check out the iCloud settings in iOS (under Storage & Backup > Manage Storage).

I can see that my HTML5 iOS app is being backed up to iCloud. And that includes the data in the localStorage :)

I believe that means if you have multiple devices, that the localStorage would be synced between them - although I have not confirmed that myself. I'm not sure how iOS would deal with conflicts in the localStorage file actually.

I'm with @asgeo1 on this on this one. An phonegap app I just submitted has been rejected by apple because it makes heavy usage of local storage of temporary files and these were being entered into backups on icloud.

The fix is to add this to your config.xml:

<preference name="BackupWebStorage" value="none" />

Just like asgeo1 says, localstorage does get saved to the iCloud. You can turn this off by setting BackupWebStorage to none in the config.xml. Here is a link to the Phonegap documentation.

Note that only user data may be stored to the iCloud. Data that is needed for offline purposes may not be stored in the iCloud. Here is a link to Apple's Q&A.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top