prevent data from being backup on icloud

I’m having a problem with my app on ios, on my app i saving data on persistent data path, that i download with WWW class, but apple reject my app because this data is being backup on icloud, but i need this data to be download, to function my app correctly and if the device is offline, use this data to make the work correctly.

So they redirect me to this page: Q&A of how to prevent data being backup on icloud but this for a xcode project on object C, so how can i prevent that the data that i download and save is not being backup on icloud.

Apple wants to prevent very large files that are not critical to the application’s functioning from being backed up to iCloud. What this means is that if the file can be recreated from a download (it sounds like this is the case in your app) then you need to set the ‘Do not back up’ attribute on the file after it’s finished downloading.

Now, one issue is you’re inside Unity after you download it. I can’t help you get from Unity to Objective-C but here is the code I use in another application to set a file at a particular path to not back up (This is objective-c code)

+(bool)addSkipBackupAttributeToItemAtPath:(NSString*)path
{
    const char* filePath = [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;
}

Search around for ‘com.apple.MobileBackup’ on Google and you might get what you need.

Thanks i used you code to do not backup on icloud a database that i have, but that i copied from appcontroller.mm, but the images that i download inside unity i don’t know how to prevent from being backup, but thanks anyway because i resolve one file from being copied to the icloud

Use iPhone.SetNoBackupFlag (pathtofile)

http://docs.unity3d.com/Documentation/ScriptReference/iPhone.SetNoBackupFlag.html