简体   繁体   中英

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. 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:

ObjC

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

To get the build number as a NSString variable:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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