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