首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在iOS中使用深度链接检查应用程序版本

在iOS中使用深度链接检查应用程序版本
EN

Stack Overflow用户
提问于 2016-01-25 10:24:41
回答 1查看 961关注 0票数 0

如何使用iOS中的深度链接来检查应用程序的当前安装版本,这样我们就可以提示用户升级应用程序。从safari浏览器,我想导航到应用程序。但根据要求,我需要检查安装版本的应用程序。如果安装了以前的版本,我们需要提示用户更新应用程序。

EN

回答 1

Stack Overflow用户

发布于 2016-01-25 10:41:15

你可以得到

您在Xcode目标摘要的"Version“字段中设置的值位于以下位置:

ObjC

代码语言:javascript
代码运行次数:0
运行
复制
NSString *Currentversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

要将构建编号作为NSString变量获得:

代码语言:javascript
代码运行次数:0
运行
复制
NSString * CurrentbuildNo = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

,例如

你也许可以这样做:

代码语言:javascript
代码运行次数:0
运行
复制
- (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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34990202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档