【问题标题】:App rejected due to data storeage应用因数据存储而被拒绝
【发布时间】:2016-09-07 18:25:18
【问题描述】:

我的应用被拒绝,因为它必须遵循 iOS 数据存储指南。我已经在stackoverflow上阅读了一些答案,并且我已经阅读了一些博客......我知道我的问题,在第一次应用程序启动时我从服务器下载解压缩sqlite db文件并压缩它,之后我从临时文件夹中删除解压缩文件.

我也在使用下面的代码。

+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
    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;
     }

在这里调用这个方法:-

+ (void) createEditableCopyOfDatabaseIfNeeded
  {     
NSLog(@"Creating editable copy of database");   
    BOOL success; 
    NSFileManager *fileManager = [NSFileManager defaultManager];    NSError *error;     
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ddb];
    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:writableDBPath]];

    success = [fileManager fileExistsAtPath:writableDBPath]; 
    if (success)    
{   
    NSLog(@"ALready exists");       return; 
    } 
    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:ddb];    
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:defaultDBPath]]; 
    if (!success)   
{       
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]); 
    }
    NSURL * fileURL;
    fileURL = [ NSURL fileURLWithPath: ddb ];

    [ fileURL setResourceValue: [ NSNumber numberWithBool: YES ] forKey: NSURLIsExcludedFromBackupKey error: nil ];
 }

我的申请还是被拒绝了。请帮忙。

我收到了苹果的回复。

May 12, 2016 at 1:59 AM
From Apple
2.23 - Apps must follow the iOS Data Storage Guidelines or they will be rejected
Thank you for your resubmission. During our continued review, we found the following issue unresolved:

2.23 Details

On launch and content download, your app still stores 78.84 MB on the user's iCloud, which does not comply with the iOS Data Storage Guidelines.

Next Steps

Please verify that only the content that the user creates using your app, e.g., documents, new files, edits, etc. is backed up by iCloud as required by the iOS Data Storage Guidelines. Also, check that any temporary files used by your app are only stored in the /tmp directory; please remember to remove or delete the files stored in this location when it is determined they are no longer needed.

Data that can be recreated but must persist for proper functioning of your app - or because users 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 kCRUFLIsExcludedFromBackupKey attribute.

Resources

To check how much data your app is storing:

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

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

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

【问题讨论】:

  • 您下载并压缩的数据库大小是多少?
  • 你能分享你从苹果那里得到的消息吗?
  • @KevinMac 我的解压 30mb 和 82.6 MB
  • 您需要阻止应用自动将大文件复制到 iCloud。
  • @ElTomato 如何停止自动将文件复制到 icloud,因为在我的 Targets->Capabilities 他们没有 iCloud 选项。而且我已经使用了 [fileURL setResourceValue: [ NSNumber numberWithBool: YES] forKey: NSURLIsExcludedFromBackupKey错误:无];

标签: ios objective-c sqlite icloud


【解决方案1】:
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ddb];

这有点指出 ddb 是一些随机字符串。

   NSURL * fileURL;
  fileURL = [ NSURL fileURLWithPath: ddb ];
  [fileURL setResourceValue: [ NSNumber numberWithBool: YES ] forKey: NSURLIsExcludedFromBackupKey error: nil ];

这里你没有得到你复制数据库的路径,而是 只是用字符串值打开 url,这就是我认为它失败的原因。 要修复此调用此行之后的方法

success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
[self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:writableDBPath]];

【讨论】:

    【解决方案2】:

    (1) 确保您的大文件位于 Library 文件夹中。 (2) 在 AppDelegate.m 中使用 NSURLIsExcludedFromBackupKey 选项或 addSkipBackupAttributeToItemAtPath 。

    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        /* create a file outside of the Document folder like filePath1 */
    
        /* preven os from copying data file for iCloud */
        [self addSkipBackupAttributeToItemAtPath:[self filePathA]];
    
        return YES;
    }
    
    - (NSString *)filePathA {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
        return [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Data"];
    }
    
    - (NSString *)filePath1 {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
        return  [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"Data"] stringByAppendingPathComponent:@"Data1.data"];
    }
    
    - (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)path {
        NSURL *url = [NSURL fileURLWithPath: path];
        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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-19
      • 1970-01-01
      • 2023-03-24
      • 2016-09-16
      • 2012-02-18
      • 2016-08-09
      • 2022-01-01
      • 2017-02-04
      相关资源
      最近更新 更多