IOS development determines the current APP version and upgrade, iosapp

Source: Internet
Author: User

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];}

  

 

Related Article

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.