iOS企业版使用第三方实现自动更新版本
1、獲取本地版本和互聯(lián)網(wǎng)版本 ? ??
? ??NSDictionary *infoDictionary = [[NSBundle?mainBundle] infoDictionary];
? ? NSString * localVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
? ? NSString * netVersion = [NSString?stringWithFormat:@"%@",paramDic[@"clientVersion"]];
2、比較本地版本和互聯(lián)網(wǎng)版本,如果存在最新版本,去下載
3、使用第三方平臺網(wǎng)站 ??fir.im ? 上的工具,可以實現(xiàn)自動更新
3.1、查詢平臺上需要安裝的版本
[NSStringstringWithFormat:@"http://api.fir.im/apps/%@/download_token?api_token=%@",idstr,token]
3.2、獲得直接安裝的地址
NSString * downloadUrl =?[NSStringstringWithFormat:@"https://download.fir.im/apps/%@/install? download_token=%@",idstr,downloadtoken]
? ??3.3、需要把地址編碼,然后轉(zhuǎn)為小寫
? ? NSString *encodeUrl = [downloadUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet? URLHostAllowedCharacterSet]];
? ??NSString *url =[NSString?stringWithFormat:@"itms-services://?action=download-manifest&url=%@", [[encodeUrl stringByReplacingOccurrencesOfString:@"="withString:@"%3d"] lowercaseString]];
4、自動下載最新版本
? ??if ([[UIApplication?sharedApplication] canOpenURL:[NSURL?URLWithString:url]]) {
? ? ? ? [[UIApplication?sharedApplication]openURL:[NSURL?URLWithString:url] options:@{}completionHandler:nil];? }
轉(zhuǎn)載于:https://www.cnblogs.com/shizhiliblog/p/8267064.html
總結(jié)
以上是生活随笔為你收集整理的iOS企业版使用第三方实现自动更新版本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#模板设计模式使用和学习心得
- 下一篇: Python打包工具setuptools