IOS Version Auto-update

Source: Internet
Author: User

appdelegate.h-  (BOOL) Application: (uiapplication *) Application didfinishlaunchingwithoptions: ( nsdictionary *) launchoptions {   [self  editionupdate];} Version Automatic Update-(void) editionupdate{   nsstring * [email protected] "192.168 ..."; /Get the Backend interface    //    nsstring * url=[nsstring stringwithformat:@ " //Get App store interface//Use synchronous request to parse data     nsmutableurlrequest *request=[[ Nsmutableurlrequest alloc]init];    [request seturl:[nsurl urlwithstring: Url]];    nsdata *returndata=[nsurlconnection sendsynchronousrequest:request  returningresponse:nil error:nil];    nsdictionary *jsondata=[ nsjsonserialization jsonobjectwithdata:returndata options:0 error:nil ];     nsstring *updateversion=[jsondata objectforkey:@ ' version '];//version number     _updateurl=[jsondata objectforkey:@ "Trackviewurl"];//         //get the current version of the app     nsstring *version =  [[[nsbundle mainbundle] infodictionary] objectforkey:@ "CFBundleShortVersionString"];         //to double type     double currentversion =[version doublevalue];    double updaversion=[updateversion doublevalue];         if  (currentversion<updaversion)  {         uialertview *alert=[[uialertview alloc]initwithtitle:@ "Tips"   message:@ "A new version can be updated"  delegate:self cancelbuttontitle:@ "Cancel"  otherbuttontitles:@ "Upgrade", nil];         [alert show];                  }}//alertview delegate -(void) Alertview: (uialertview *) AlertView  clickedbuttonatindex: (Nsinteger) buttonindex{    if  (buttonIndex==1)  {    //  Open the app in AppStore by getting to the URL and jump to the app download page         [[ uiapplication sharedapplication]openurl:[nsurl urlwithstring:_updateurl]];    }}


IOS Version Auto-update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.