IOS development determines the current APP version and upgrade, iosapp
Starting from the iOS8 system, you can set it in the settings to automatically update the installed App in the WiFi environment. This function greatly facilitates users, but some users do not enable this function, so you still need to prompt users in the program
Method 1: Specify the corresponding data in the server interface. In this way, the server directly transmits the information, prompting the user to have a new version and can upgrade it to the store.
Note: This method is faulty. If your App has not been approved and the mobile background data has been updated, the version number returned by the background is the latest version number, the old version will prompt users to upgrade. However, after clicking upgrade, the user jumps to the AppStore and finds that the App has not been updated.
Method 2: Check the version of the App installed on the mobile phone, and then combine it with the version information of the App on the App Store to determine (currently the most common method)
Step 1: Obtain the currently running version information, which can be obtained through the bundle version in the info. plist File
NSDictionary * infoDic = [[NSBundle mainBundle] infoDictionary]; // The current version NSString * currentVersion = [infoDic objectForKey: @ "cfbundlepolicversionstring"];
Step 2: Obtain the App version information in the AppStore
-(Void) judgeAppVersion {
// AppStore access address (key) NSString * urlStr = @ "https://itunes.apple.com//lookup? Id = AppID "; NSURL * url = [NSURL URLWithString: urlStr]; NSURLRequest * req = [NSURLRequest requestWithURL: url]; [NSURLConnection connectionWithRequest: req delegate: self];} # pragma mark-NSURLConnectionDataDelegate-(void) connection :( NSURLConnection *) connection didReceiveData :( NSData *) data {NSError * error;
// Parse NSDictionary * appInfo = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingAllowFragments error: & error]; NSArray * infoContent = [appInfo objectForKey: @ "results"]; // The latest version NSString * version = [[infoContent objectAtIndex: 0] objectForKey: @ "version"]; // URL of the application (User-Defined jump URL) NSString * trackViewUrl = [[infoContent objectAtIndex: 0] objectForKey: @ "trackViewUrl"];}
Parse the App information obtained from the AppStore (here we will only introduce the key information)
MinimumOsVersion = "8.0"; // The minimum supported iOS system fileSizeBytes =; // application size releaseDate = ""; // trackCensoredName = ""; // review name trackContentRating = ""; // rating trackId =; // application IDtrackName = ""; // Application name trackViewUrl = ""; // application URL version = "4.0.3"; // version
Step 3: Check whether the current online App version is consistent with the App version used
If (! [Version isEqualToString: currentVersion]) {[SimplifyAlertView alertWithTitle: @ "check for updates: I" message: [NSString stringWithFormat: @ "check for new versions (% @), upgrade ", version] operationResult: ^ (NSInteger selectedIndex) {if (selectedIndex = 1) {[[UIApplication sharedApplication] openURL: [NSURL URLWithString: trackViewUrl] ;}} cancelButtonTitle: @ "cancel" otherButtonTitles: @ "Upgrade", nil];}