简体   繁体   English

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

[英]check app version using deep linking in iOS

How can we check current installed version of our app using deep linking in iOS, so that we can prompt user to upgrade the app. 我们如何使用iOS中的深层链接检查应用程序的当前安装版本,以便提示用户升级应用程序。 From safari browser, I want to navigate to app. 从野生动物园浏览器,我想导航到应用程序。 But as per requirement, I need to check installed version of the app. 但根据要求,我需要检查该应用程序的安装版本。 If previous version is installed, we need to prompt user to update the app. 如果安装了以前的版本,我们需要提示用户更新应用。

you can get as 你可以得到

The value you set in the Xcode target summary's "Version" field is in here: 您在Xcode目标摘要的“版本”字段中设置的值位于此处:

ObjC 对象

NSString *Currentversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

To get the build number as a NSString variable: 要将内部版本号作为NSString变量获取:

NSString * CurrentbuildNo = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];

For Example 例如

You could probably do like this: 您可能会这样:

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

for more reference 以获得更多参考

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

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