I would like to store some data files in a quite permanent location, which should not be synchronized with iCloud.
Following Cordova documentation, cordova.file.cacheDirectory
is my best option:
cordova.file.cacheDirectory
- Directory for cached data files or any files that your app can re-create easily. The OS may delete these files when the device runs low on storage, nevertheless, apps should not rely on the OS to delete files in here
In order to control if I reach my goal, I check the size of data synchronized by iCloud:
- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage
- If necessary, tap "Show all apps" Check your app's storage
Well, my app is always so heavy...
Here is what I did so far :
config.xml
<preference name="BackupWebStorage" value="none" />
<preference name="iosPersistentFileLocation" value="Library" />
Javascript
function onDeviceReady(){
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem ;
window.requestFileSYstem(LocalFileSystem.PERSISTENT, 0, gotFS, function(){
console.log('Error FS');
});
}
function gotFS(fileSystem){
window.cacheFS = fileSystem.cacheDirectory;
}
document.addEventListener('deviceReady', onDeviceReady, false);
and then, I use cacheFS.toURL()
as a base directory to store the files.
Can you see what I missed?
Apple says that data that should not be synchronized should have a "do not backup" attribute, NSURLIsExcludedFromBackupKey
attribute for NSURL objects, kCFURLIsExcludedFromBackupKey
attribute for CFURLRef objects. I don't know what those objects are, and how to apply attributes with Cordova...
Indeed, I discovered a NoCloud
folder created at the root of the app document directory. All data stored in this folder is not uploaded to iCloud.