Reputation: 109
I'm reading many question about this problem. I'm using Phonegap for my app. My app download about 3mb of images. Apple reject my app and suggest to apply "do not backup attribute" to all files.How do I prevent files from being backed up to iCloud and iTunes?
I use this code for my 5.1 app:
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
I put it in my AppDelegate.m . Is it correct?
Upvotes: 0
Views: 1592
Reputation: 161
This should be the correct code that is working at my side :
var DATADIR;
var knownfiles = [];
function init() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFSSuccess, null);
}
function onFSSuccess(fileSystem) {
console.log("here I am");
fileSystem.root.getDirectory("it.mns.dcsofficebp",{create:true},gotDir,false);
}
function gotDir(d){
DATADIR = d;
DATADIR.setMetadata(onSetMetadataSuccess, onSetMetadataFail, { "com.apple.MobileBackup": 1});
}
function onSetMetadataSuccess() {
console.log("success setting metadata - DONE DONE DONE!")
}
function onSetMetadataFail() {
console.log("error setting metadata")
}
This is my result : 2012-12-14 12:46:20.064 testproj[1779:c07] [LOG] success setting metadata - DONE DONE DONE!
Upvotes: 0
Reputation: 109
This is my code
var DATADIR;
var knownfiles = [];
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFSSuccess, null);
}
//Loaded my file system, now let's get a directory entry for where I'll store my crap
function onFSSuccess(fileSystem) {
fileSystem.root.getDirectory("it.mns.dcsofficebp",{create:true},gotDir,onError);
}
//The directory entry callback
function gotDir(d){
DATADIR = d;
var reader = DATADIR.createReader();
localStorage.setItem("datadir",JSON.stringify(DATADIR));
reader.readEntries(function(d){
appReady();
},onError);
}
//Result of reading my directory
function gotFiles(entries) {
for (var i=0; i<entries.length; i++) {
knownfiles.push(entries[i].name);
renderPicture(entries[i].fullPath);
}
}
Where i need to put
parent.setMetadata(onSetMetadataSuccess, onSetMetadataFail, { "com.apple.MobileBackup": 1});
Upvotes: 0
Reputation: 161
Where are you storing the files at the moment? I guess you are you using the standard Phonegap example :
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);
A solution is using the code below for your FileSytem request, which will requets the temporary dir of your app :
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onSuccess, onError);
The LocalFileSystem.TEMPORARY
on iOS would point to
/var/mobile/Applications/CEEECEA6-4684-4599-B0BF-407BE2CBD3CE/tmp
Kind regards,
Mike
Upvotes: 1