0

この問題について多くの質問を読んでいます。アプリに Phonegap を使用しています。私のアプリは約3MBの画像をダウンロードします。Apple は私のアプリを拒否し、すべてのファイルに「バックアップしない属性」を適用することを提案します。ファイルが iCloud や 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 に入れました。それが正しいか?

4

3 に答える 3

1

現在、ファイルをどこに保存していますか? 標準の Phonegap の例を使用していると思います。

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

解決策は、アプリの一時ディレクトリを要求する FileSytem リクエストに以下のコードを使用することです。

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

LocalFileSystem.TEMPORARYiOSのは、

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

敬具、

マイク

于 2012-12-14T10:29:14.907 に答える
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] [ログ] メタデータの設定成功 - DONE DONE DONE!

于 2012-12-14T11:27:59.617 に答える
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});
于 2012-12-14T11:22:19.163 に答える