繁体   English   中英

使用iOS中的深层链接检查应用程序版本

[英]check app version using deep linking in iOS

我们如何使用iOS中的深层链接检查应用程序的当前安装版本,以便提示用户升级应用程序。 从野生动物园浏览器,我想导航到应用程序。 但根据要求,我需要检查该应用程序的安装版本。 如果安装了以前的版本,我们需要提示用户更新应用。

你可以得到

您在Xcode目标摘要的“版本”字段中设置的值位于此处:

对象

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;;
}

以获得更多参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM