应用程序因数据存储而被拒绝

时间:2016-05-12 05:35:59

标签: ios objective-c sqlite icloud

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

我也在使用以下代码。

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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

(1)确保您的大文件位于文件夹中。 (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;
}