IOS fixes for version upgrade issues

Source: Internet
Author: User

Starting from the IOS8 system, users can set up the app in the WiFi environment and automatically update the installed apps. This feature greatly facilitates the user, but some users do not turn on this feature, so still need to prompt the user in the program.

Although the Apple audit cannot now see the feature and typeface and features of the version prompt update. But some app planners still want to provide these features. Here are the main two ways of thinking.

Method One

The server interface contracts the corresponding data, so that the server passes information directly, prompting the user to have a new version, you can go to the store upgrade

However, this method is problematic, because your app in the audit process can not be updated, so in the audit process will need to return the interface field is a new version, this time the old user will receive the update prompt, but the new version is still in the process of review. Work.

Workaround

Still need background cooperation, you can send the request at the time of your current version number sent to the background let the background to determine that should not return the updated version of the information.

Method Two

Detects the version of the app installed on your phone and then compares it to the version information on the App Store (currently the most common method)

Step one: Get information about the currently running version obtained through the info.plist bundle version

Nsdictionary *infodic = [[NSBundle Mainbundle] infodictionary]; // Current Version number NSString *currentversion = [infodic objectforkey:@ "cfbundleshortversionstring"];

Step two: Get the app version information in AppStore

-(void) judgeappversion{<br>//AppStore Access Address (emphasis)NSString *urlstr =@"Https://itunes.apple.com//lookup?id=AppID"; Nsurl*url =[Nsurl Urlwithstring:urlstr]; Nsurlrequest*req =[Nsurlrequest Requestwithurl:url]; [Nsurlconnection connectionwithrequest:reqDelegate: self];}#pragmamark-nsurlconnectiondatadelegate-(void) Connection: (Nsurlconnection *) connection didreceivedata: (NSData *) data{Nserror*error;<br>//parsingNsdictionary *appinfo = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingallowfragments error:&ERROR]; Nsarray*infocontent = [AppInfo objectforkey:@"Results"]; //Latest Version NumberNSString *version = [[Infocontent objectatindex:0] Objectforkey:@"version"]; //Application Introduction URL (User upgrade jump URL)NSString *trackviewurl = [[Infocontent objectatindex:0] Objectforkey:@"Trackviewurl"];}

Parse the app information obtained from AppStore (this is only the information that is used in the focus)

Minimumosversion ="8.0";//the minimum iOS system supported by the appFilesizebytes =;//the size of the appReleaseDate ="";//Release TimeTrackcensoredname ="";//Review NameTrackcontentrating ="";//ratingTrackID =;//Application IDTrackName ="";//Application NameTrackviewurl ="";//Application Introduction URLVersion ="4.0.3";//Version number

Step three: Determine if the current online app version number is consistent with the app version number you are using

if(![version isequaltostring:currentversion]) {[Simplifyalertview alertwithtitle:@"Check for updates: I shop"Message:[nsstring stringWithFormat:@"discover new version (%@), whether to upgrade", Version] operationresult:^(Nsinteger selectedindex) {if(SelectedIndex = =1{[[uiapplication sharedapplication] Openurl:[nsurl Urlwithstring:trackviewurl]]; }} Cancelbuttontitle:@"Cancel"Otherbuttontitles:@"Upgrade", nil]; }

IOS fixes for version upgrade issues

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.