2.23应用必须遵循iOS数据存储指南,否则将被拒绝

时间:2012-12-14 09:48:56

标签: ios objective-c cordova appstore-approval

我正在阅读很多关于这个问题的问题。我正在为我的应用程序使用Phonegap。 我的应用程序下载约3mb的图像。 Apple拒绝我的应用并建议对所有文件应用“请勿备份属性”。How do I prevent files from being backed up to iCloud and iTunes?

我将此代码用于我的5.1应用程序:

- (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;
 }

我把它放在我的AppDelegate.m中。这是对的吗?

3 个答案:

答案 0 :(得分:1)

您目前在哪里存储文件?我想你是在使用标准的Phonegap示例:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);

解决方案是使用下面的代码来处理您的FileSytem请求,该请求将重新询问您应用的临时目录:

window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onSuccess, onError);

iOS上的LocalFileSystem.TEMPORARY会指向

/var/mobile/Applications/CEEECEA6-4684-4599-B0BF-407BE2CBD3CE/tmp

亲切的问候,

麦克

答案 1 :(得分:0)

这是我的代码

   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);
          }
      }

我需要放的地方

parent.setMetadata(onSetMetadataSuccess, onSetMetadataFail, { "com.apple.MobileBackup": 1});

答案 2 :(得分:0)

这应该是我身边正确的代码:

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")
}

这是我的结果:2012-12-14 12:46:20.064 testproj [1779:c07] [LOG]成功设置元数据 - 完成完成!