[英]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.