iOS企業版使用第三方實現自動更新

來源:互聯網
上載者:User

標籤: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企業版使用第三方實現自動更新

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.