標籤:net 新版本 sdi service 最新 handle http download com
1、擷取本地版本和互連網版本
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString * localVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString * netVersion = [NSString stringWithFormat:@"%@",paramDic[@"clientVersion"]];
2、比較本地版本和互連網版本,如果存在最新版本,去下載
3、使用第三方平台網站 fir.im 上的工具,可以實現自動更新
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、需要把地址編碼,然後轉為小寫
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]; }
iOS企業版使用第三方實現自動更新