gpt4 book ai didi

objective-c - 不要备份到 iCloud 但仍然被拒绝

转载 作者:IT王子 更新时间:2023-10-29 08:20:28 25 4
gpt4 key购买 nike

在我的应用程序中,我必须存储核心数据数据库和音频文件,所以我解码以将它们放在文档目录中。为了防止他们备份,当我第一次启动应用程序时,我将 Don't BackUp flag like this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self addSkipBackupAttributeToItemAtURL:[self applicationDocumentsDirectory]];
}
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
- (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
return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
}
}

但它似乎不起作用 - 我仍然被拒绝:

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

In particular, we found that on launch and/or content download, your app stores 3.6 MB. To check how much data your app is storing:

  • Install and launch your app
  • Go to Settings > iCloud > Storage & Backup > Manage Storage
  • If necessary, tap "Show all apps"
  • Check your app's storage

另一个问题是我无法检查 - 我没有在

中看到我的应用程序

Settings > iCloud > Storage & Backup > Manage Storage

也许问题只出在 5.0 上,我在这里没有考虑到这一点?

最佳答案

问题出在 iOS 5.0 上,在这个 iOS 中你不应该放置 dont backup 标志不备份标志是在 ios 5.0.1 中引入的我们的应用程序确实遇到了类似的问题,它已经被拒绝了好几次所以我们不得不做一些工作来处理不同的 iOS我们需要支持 iOS < 5.0、iOS 5.0 和 iOS > 5.0

于是联系了apple之后,除了在不同的iOS上有不同的路径之外,没有找到任何解决方案

我们有这样一个函数:

+ (NSString*) savePath
{
NSString *os5 = @"5.0";

NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4
{
return path;
}
else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above
{
return path;
}
else // IOS 5
{
path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
return path;
}

return nil;
}

我们曾经并且仍然使用这个功能。

请阅读更多

iOS 5.0

It is not possible to exclude data from backups on iOS 5.0. If your app must support iOS 5.0, then you will need to store your app data in Caches to avoid that data being backed up. iOS will delete your files from the Caches directory when necessary, so your app will need to degrade gracefully if it's data files are deleted.

http://developer.apple.com/library/ios/#qa/qa1719/_index.html

关于objective-c - 不要备份到 iCloud 但仍然被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10891271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com