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.
Asked
Active
Viewed 1,006 times
0
-
i guess you can do it in the app itself, and you check the version in : - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation so that you open the application first – Mejdi Lassidi Jan 25 '16 at 10:33
-
The Appstore app updates the App automatically now so if the user has disabled this feature then they probably know about the fact that their apps are not being updated. – jAmi Jan 25 '16 at 10:43
-
I think this can only be done in app side instead of the safari side. Or you can tried to set a share cookies in the app storing the version info, then read it in js. – xi.lin Jan 25 '16 at 10:59
1 Answers
1
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

Community
- 1
- 1

Anbu.Karthik
- 82,064
- 23
- 174
- 143