有没有一种方法可以测试应用程序何时更新?
我很尴尬,因为有一个错误只在应用程序更新时出现,并且没有调查。
如果您问是否想通过应用程序商店查找应用程序何时更新,我不知道有这样的方法。
执行此操作的一种黑客方法是将当前应用程序版本保存到 NSUserDefaults,然后检查 NSUserDefaults 应用程序版本是否等于当前应用程序版本。
例如:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
if ([defaults objectForKey:@"savedAppVersionKey"] != nil) {
//key exists
NSString *savedAppVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedAppVersionKey"];
if ([currentAppVersion isEqualToString:savedAppVersion]) {
//still running the same app version
}
else {
//the app version changed from the last launch
}
}
else {
//first run, set the key & synchronize
[[NSUserDefaults standardUserDefaults] setObject:currentAppVersion forKey:@"savedAppVersionKey"];
[[NSUserDefaults standardUserDefaults] synchronize]
}
}
我还没有测试过代码,但它应该可以工作。
Thanks,
-David
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)