【问题标题】:Excluding the Documents Directory from iCloud Backup从 iCloud 云备份中排除文档目录
【发布时间】:2015-02-21 12:21:50
【问题描述】:

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

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 线程,我现在尝试了六种不同的方法,都失败了。 :(

编辑:添加拒绝通知

----- 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

【问题讨论】:

  • 什么是拒绝通知?
  • @Zaph 添加了通知。

标签: ios icloud


【解决方案1】:

阅读Technical Q&A QA1719

基本上每个文件都必须将键“NSURLIsExcludedFromBackupKey”设置为“YES”。

您可以将清单 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;
}

【讨论】:

  • 太棒了,这会禁用 Documents 文件夹中的所有备份? Documents 目录中的特定文件夹呢?
猜你喜欢
  • 2012-08-19
  • 2014-10-20
  • 1970-01-01
  • 2020-07-05
  • 1970-01-01
  • 2013-04-25
  • 2013-06-24
  • 2013-04-17
  • 2015-12-03
相关资源
最近更新 更多