从iCloud备份中排除文档目录 [英] Excluding the Documents Directory from iCloud Backup

查看:99
本文介绍了从iCloud备份中排除文档目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我现在正在使用的代码,但是,Apple仍然向我发送了拒绝"通知:

Here is the code that I'm using right now, however, Apple still sent me the 'Rejection' notice:

didFinishLaunchingWithOptions:

NSString *docsDir;
NSArray *dirPaths;
NSURL *finalURL;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];

finalURL = [NSURL fileURLWithPath:docsDir];

[self addSkipBackupAttributeToItemAtURL:finalURL];

我恳请您不要将我重定向到另一个Stack Overflow线程,我现在尝试了六种不同的方法,所有方法均无法正常工作. :(

I beg that you please do not redirect me to another Stack Overflow thread, I have tried six different methods now, all failed to work. :(

添加了拒绝通知

----- 2.23 -----

We found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.

In particular, we found that on launch and/or content download, your app stores 102.71MB. To check how much data your app is storing:

- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage 
- If necessary, tap "Show all apps" 
- Check your app's storage

The iOS Data Storage Guidelines indicate that only content that the user creates using your app, e.g., documents, new files, edits, etc., should be backed up by iCloud. 

Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.

Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute. 

For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?.

It is necessary to revise your app to meet the requirements of the iOS Data Storage Guidelines. 
If you have difficulty reproducing a reported issue, please try testing the workflow described in Technical Q&A QA1764: How to reproduce bugs reported against App Store submissions.

If you have code-level questions after utilizing the above resource, you may wish to consult with Apple Developer Technical Support. When the DTS engineer follows up with you, please be ready to provide:

- complete details of your rejection issue(s)
- screenshots
- steps to reproduce the issue(s)
- symbolicated crash logs - if your issue results in a crash log

推荐答案

阅读 Q&A QA1719技术问答.

基本上每个文件必须将键"NSURLIsExcludedFromBackupKey"设置为是".

Essentially each file must have the key "NSURLIsExcludedFromBackupKey" set to "YES".

您只需将清单1中的方法添加到代码中,然后在存储的每个文件上调用它.

You can just add the method in Listing 1 to your code and call it on each file stored.

为完整起见,以下是方法:

For completeness below is the method:

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

这篇关于从iCloud备份中排除文档目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆