// 1、填寫(xiě)自己App的ID
NSString * strurl = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=1491881948"];//替換為自己App的ID
NSURLSession *session=[NSURLSession sharedSession];
NSURL *url = [NSURL URLWithString:strurl];
//2.創(chuàng)建可變的請(qǐng)求對(duì)象
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error){
//4.解析數(shù)據(jù)
NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSArray * results = dict[@"results"];
NSDictionary * dic = results.firstObject;
NSString * lineVersion = dic[@"version"];//版本號(hào)
NSString * releaseNotes = dic[@"releaseNotes"];//更新說(shuō)明
NSString * trackViewUrl = dic[@"trackViewUrl"];//鏈接
DSLog(@"App store版本號(hào):%@",lineVersion);
DSLog(@"更新說(shuō)明:%@",releaseNotes);
DSLog(@"App下載鏈接:%@",trackViewUrl);
// 5、獲取本地版本
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// 本地app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// 6、比較版本信息
if ([lineVersion floatValue] > [app_Version floatValue]) {
// 7、回到主線程進(jìn)行后續(xù)操作
dispatch_async(dispatch_get_main_queue(), ^{
[self setGengxinUI];
});
DSLog(@"^^%@",app_Version);
}else{
// 7、回到主線程進(jìn)行后續(xù)操作
dispatch_async(dispatch_get_main_queue(), ^{
[SOSVC SOSToolTipShow:@"提示" message:@"已是最新版本" cancelTitle:@"確定" otherTitle:nil];
});
}
}];
//3.執(zhí)行任務(wù)
[dataTask resume];
iOS 獲取當(dāng)前app的 App Store 版本號(hào)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- // 當(dāng)前app的信息 NSDictionary*infoDictionary=[[NSBundlemainBun...
- 如題, 今天我來(lái)給大家介紹: 一, 如何從App Store獲取自己APP的版本號(hào); 二, 如何判斷本地版本與Ap...
- (http://upload-images.jianshu.io/upload_images/1197386-a0...
- 近期做到APP的更新,當(dāng)新應(yīng)用更新后,本地的APP也需要更新,這個(gè)時(shí)候給用戶一個(gè)提示就比較好了。相關(guān)代碼如下,寫(xiě)在...
- 轉(zhuǎn)自:http://www.itdecent.cn/p/10b2323f502e 1、禁止手機(jī)睡眠 [UIApp...