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