1- (void) Checkupdatewithappid: (NSString *) AppID success: (void(^) (Nsdictionary *resultdic, BOOL isnewversion, NSString * newversion, NSString * currentversion)) Success Failure: (void(^) (Nserror *error)) failure{2Afhttpsessionmanager *manager =[Afhttpsessionmanagermanager];3Manager.requestserializer=[Afhttprequestserializerserializer];4Manager.responseserializer=[Afhttpresponseserializerserializer];5 6//7NSString *encodingurl=[[@"http://itunes.apple.com/lookup?id="Stringbyappendingstring:@"Unique ID of the app"]stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];8 9[Manager Get:encodingurl parameters:nilprogress:^ (nsprogress *_nonnull downloadprogress) {Ten One} success:^ (Nsurlsessiondatatask *_nonnull task,ID_nullable Responseobject) { A -Nsdictionary *resultdic=[Nsjsonserializationjsonobjectwithdata:responseobject Options:NSJSONReadingMutableLeaveserror:nil]; - the //gets the version number of the AppStore -NSString * Versionstr =[[[resultdic Objectforkey:@"Results"]objectatindex:0]valueforkey:@"version"]; - -NSString *versionstr_int=[versionstr stringbyreplacingoccurrencesofstring:@"."Withstring:@""]; + - intversion=[Versionstr_intintvalue]; + A //get the local version number atNsdictionary *infodic=[[NSBundle Mainbundle] infodictionary]; - -NSString * CurrentVersion = [Infodic valueforkey:@"cfbundleshortversionstring"]; - -NSString *currentversion_int=[currentversion stringbyreplacingoccurrencesofstring:@"."Withstring:@""]; - in intCurrent=[Currentversion_int intvalue]; - to if(version>Current ) { + success (Resultdic,yes, versionstr,currentversion); -}Else{ the success (Resultdic,no, versionstr,currentversion); * } $} failure:^ (Nsurlsessiondatatask *_nullable task, Nserror *_nonnull Error) {Panax Notoginseng failure (error); - }]; the } + A the //called + - $Versionupdate *tool=[[Versionupdatealloc]init]; $__weaktypeof (self) weakself=Self ; -[Tool Checkupdatewithappid:@""success:^ (nsdictionary *resultdic,bool isnewversion, NSString *newversion, NSString *CurrentVersion) { - if(isnewversion) {//indicates that you want to update the version theNsmutabledictionary *dict=[[Nsmutabledictionary alloc]init]; -NSString *key=[nsstring stringWithFormat:@"%@%@", currentversion,newversion];WuyiNSString *value=[S.versionupdatemessage Objectforkey:key]; the intTime =[value intvalue]; - if(time<3&&_versionupdatevc==nil) {//less than three times to continue the bullet box Wutime+=1; -[Dict setvalue:[nsstring stringWithFormat:@"%d", Time]forkey:key]; AboutS.versionupdatemessage=[Nsdictionary dictionarywithdictionary:dict]; $_VERSIONUPDATEVC = [[Versionupdatecontroller alloc]initwithcontent:[[[resultdic Objectforkey:@"Results"]firstobject]objectforkey:@"releasenotes"]];//Releasenotes,appstore The above app update content - [_versionupdatevc addselffromsuperwithversionstr:newversion]; -}Else{//More than three times do not do any action - [Weakself Joingroupview]; A } + } the} failure:^ (Nserror *error) { - [Weakself Joingroupview]; $}];
iOS get current AppStore version number with update