My iphone App got rejected with this reason “We found that your app does not follow the iOS Data Storage Guidelines,…”

淺唱寂寞╮ 提交于 2019-11-28 16:25:32

Check https://developer.apple.com/icloud/documentation/data-storage/

specifically:

Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory.

Store the SQLite db in the caches folder and set the donotbackup flag, which will stop the file being deleted by the cache clean system

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];

    const char* attrName = "com.apple.MobileBackup";
    u_int8_t attrValue = 1;

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
    return result == 0;
}

I use a database in my app and store it in the cache folder (with the above flag set) and just got approved no problem.

In addition you can store your data in a subfolder of the documents directory, which I believe won't get backed up, but will persist.

One of my friend has the same problem. The basic problem is You might be storing heavy data in your Application document Directory.

After iCloud is implemented in Apple, The Document directory data is somehow related with iCloud Storage. Hence Apple is now rejecting the applications using heavy data storage in document directory.

You need to store the data at some other location. Store the PDF & Other Artwork file At some other location.

This link May Help You.

http://www.techotopia.com/index.php/Working_with_Directories_on_iOS_4_%28iPhone%29

I Hope it'll Solve your problem.

To Solve Application rejected by Apple for your application does not follow the iOS Data Storage Guidelines, Please add following code in your application.

   - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
      if (&NSURLIsExcludedFromBackupKey == nil) 
      {
            // iOS <= 5.0.1  
            const char* filePath = [[URL path] fileSystemRepresentation];  
            const char* attrName = "com.apple.MobileBackup";  
            u_int8_t attrValue = 1;  
            int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);  
            return result == 0;  
       } 
       else
        {
             // iOS >= 5.1  
             NSError *error = nil;  
            // if you set YES in Resources value then iTune will not backup that file or folder.
            //  You set FALSE in Resources value then iTune will backup that file or folder.
             [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];  
             return error == nil;
        } 
}

To Use this method (Example)

NSString *defaultDBPath = [[NSBundle mainBundle] pathForResource:@"CDTDatabaseNew" ofType:@"sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
NSURL *guidesURL = [NSURL fileURLWithPath:dbPath];
[self addSkipBackupAttributeToItemAtURL:guidesURL];

You have to use this method when you are create or copy files in Document directory.

NOTE :-Apple has changed the Data storage guide line and if you are storing anything in the Document directory then you have to right the above code, Don't miss this part of code.

App will be rejected if you don't put that code. So now onwards every one must have to add that pice of code when ever you create the database, store cached images, etc. in document directory. Hope next time onwards I wan't get app rejected due to this reason.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!