iOS Development AppStore-version update

Source: Internet
Author: User

1. Version Update method

+ (void) Updatewithappid: (NSString *) AppID back: (void (^) (NSString *, NSString *, NSString *, BOOL)) back{nsdictionary *    Infodic = [[NSBundle mainbundle] infodictionary];    __block nsstring *currentversion = infodic[@ "cfbundleshortversionstring"];    __block nsstring *appstoreversion = CurrentVersion; [Self httptoolrequestwithurlstr:nil baseurl:[nsstring stringwithformat:@ "http://itunes.apple.com/cn/lookup?id=%@"        , AppID] method:getstr parameters:nil completionhandler:^ (nsurlresponse *response, id responseobject, NSError *error) {            if (responseobject) {Nsarray *results = responseobject[@ "Results"];            Nsdictionary *lastdict = [Results lastobject];            Appstoreversion = lastdict[@ "Version"];            NSString *appstoreurl = lastdict[@ "Trackviewurl"]; if (![ CurrentVersion Isequaltostring:appstoreversion]) {if (back) {Back (currentversion,appst                Oreversion,appstoreurl,yes); }}else{Do not update if (back) {back (currentversion,appstoreversion,nil,no);            }}}else{//does not update if (back) {back (currentversion,appstoreversion,nil,no); }        }    }];}

2. Page Update tips

  [Httptool updatewithappid:@ "Your AppID" back:^ (nsstring *currentversion, NSString *storeversion, NSString *openUrl, BOOL i Supdate) {if (isupdate) {Uialertcontroller *ALERTVC = [Uialertcontroll                            ER alertcontrollerwithtitle:@ "version update" message:@ "app updated, hurry to update!" Preferredstyle:uialertcontrollerstylealert]; Uialertaction *affiraction = [uialertaction actionwithtitle:@ "Update" Style:uialertactionstyledefault handler:^ (U Ialertaction * _nonnull action) {[[UIApplication sharedapplication]openurl:[nsurl Urlwiths                            Tring:openurl]];                            }];                            Uialertaction *cancelaction = [uialertaction actionwithtitle:@ "temporarily not updated" Style:uialertactionstylecancel Handler:nil];                            [ALERTVC addaction:affiraction];                            [ALERTVC addaction:cancelaction]; [Self.window.rootViewController presentviewcontroller:aLERTVC Animated:yes Completion:nil]; }                    }];

  

iOS Development AppStore-version 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.