如何使用iOS中的深度链接来检查应用程序的当前安装版本,这样我们就可以提示用户升级应用程序。从safari浏览器,我想导航到应用程序。但根据要求,我需要检查安装版本的应用程序。如果安装了以前的版本,我们需要提示用户更新应用程序。
发布于 2016-01-25 10:41:15
你可以得到
您在Xcode目标摘要的"Version“字段中设置的值位于以下位置:
ObjC
NSString *Currentversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
要将构建编号作为NSString
变量获得:
NSString * CurrentbuildNo = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
,例如
你也许可以这样做:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSString* appIDe = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
NSURL* getpath = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appIDe]];
NSData* JSONdata = [NSData dataWithContentsOfURL:getpath];
NSDictionary* JSonDiCt = [NSJSONSerialization JSONObjectWithData:JSONdata options:0 error:nil];
if ([JSonDiCt[@"resultCount"] integerValue] == 1){
NSString* currentappStoreVersion = JSonDiCt[@"results"][0][@"version"];
NSString* currentVersiononApp = infoDictionary[@"CFBundleShortVersionString"];
if (![currentappStoreVersion isEqualToString:currentVersiononApp]){
NSLog(@"Need to update");
return YES;
}else
{
//Continue your Work
}
}
return YES;;
}
关于更多的reference
https://stackoverflow.com/questions/34990202
复制相似问题