在看了一堆关于检测这是否是全新安装的帖子之后,我假设我想做的事情是不可能的,但我会问以防万一我有一个技巧不确定。
我正在构建一个要集成到应用程序中的 SDK,并且我希望能够判断 SDK 何时第一次初始化,是来自全新安装,还是来自旧版本应用程序更新,其中包括我们的 SDK。
我可以让集成商调用类似的东西,并强制他们找出它是什么(使用 NSDefaults 或其他),但我宁愿能够以某种方式自动弄清楚。
如果有人有任何想法,那就太好了。
最佳答案
我想通过使用[NSUserDefaults standardUserDefaults]来建议相当好的技巧
这样做,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if([[NSUserDefaults standardUserDefaults] boolForKey:@"isApplicationUpdated"]){
// application was updated//
// make another userDefaults to store version number and confirm if it is updated here.
}
else{
[[NSUserDefaults standardUserDefaults] setBookForKey:@"isApplicationUpdated"]
// as for the first time application would not find this key and you can use it after you have updated the app do stuff here
}
关于iOS SDK 检测应用程序是否已更新或新安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34784040/