ios應用, 設定不自動備份到iCloud

來源:互聯網
上載者:User

ios應用, 設定不自動備份到iCloud

原創文章,轉載請註明出處

ios項目,如果有內建下載或者程式動態組建檔案的話,就要注意所下載或產生的檔案,要不要自動備份到iCloud

如果沒有合適的理由就自動上傳大檔案的話,可能在不能通過應用審核. 收到一下類似這樣的回覆

We also found that your app does not follow the iOS Data Storage Guidelines, which is required per the App Store Review Guidelines.

例如有人遇到同樣問題 http://stackoverflow.com/questions/16239147/ios-do-not-back-up-attribute

蘋果給出的設定方法:官方文檔 https://developer.apple.com/Library/ios/qa/qa1719/_index.html

應用到項目中, 具體代碼如下

#define DownLoad_Directory "Download_Dir"#pragma mark Download_Dirvoid DeviceClass::initDownloadDir(){    string l_strDocumentDir = cocos2d::CCFileUtils::sharedFileUtils()->getWritablePath();    l_strDocumentDir.append(DownLoad_Directory);        NSString* l_strDownloadDir = [NSString stringWithUTF8String:l_strDocumentDir.c_str()];    NSError* l_error;    if (![[NSFileManager defaultManager] fileExistsAtPath:l_strDownloadDir]){        [[NSFileManager defaultManager] createDirectoryAtPath:l_strDownloadDir withIntermediateDirectories:NO attributes:nil error:&l_error]; //Create folder                // exclude downloads from iCloud backup        NSURL *url = [NSURL fileURLWithPath:l_strDownloadDir];        if(strcmp(g_systemVersion.c_str(), "5.1") >=0 ){            if ([url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&l_error] == NO) {                NSLog(@"Error: Unable to exclude l_strDownloadDir from backup: %@", l_error);            }        }    }        //this->setDonotBackupInICloud();}
就是在可寫目錄下建立一個新檔案夾, 存放下載檔案(需要的話,自動產生的檔案也放到這), 並標記這個目錄不會被上傳到iCloud

感謝梅俊同事的提醒


測試方法:

設定->iCloud->管理儲存空間->備份(如果有多裝置的話,選擇裝置)

應用多的話,點擊"顯示所有應用" 查到你的應用,在iCloud上備份內容的總容量.

開啟和關閉這個介面, 會發現, 你的應用在iCloud上的備份mwjg容量是不是一樣.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.