简体   繁体   中英

App rejected due to data storeage

My app was rejected cause it must follow the iOS Data Storage Guidelines. I have already read some answer here on stackoverflow, and i have already read some blogs... I know my problem, at first application launch i download unzip sqlite db file from server and zip it ,after that i remove unzip file from temp folder.

I am using following code also.

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

calling this method here:-

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

Still my application was rejected.Please help.

I got this respones from apple.

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
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ddb];

This kinda points out ddb is some random string.

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

here you are not getting the path of where you copied the db, instead just opening url with string value which is why i think it is failing. To fix this call the method after this line

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

(1) Make sure your large file is located in the Library folder. (2) Use the NSURLIsExcludedFromBackupKey option or the addSkipBackupAttributeToItemAtPath in AppDelegate.m .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM