"Go" iOS program automatically detects the implementation of the update--a good idea

Source: Internet
Author: User

Original URL: http://blog.csdn.net/davidsph/article/details/8931718

Before the project needs to use the automatic updating of the function, the implementation of the scheme is shared.
The implementation of the automatic prompt update for iOS programs is broadly divided into two types:
First, your server provides an interface that informs you about the current version of the app, whether it needs to be updated, and the updated address.
The second is to use the relevant API provided by Apple's AppStore to update the query.

Because previously did not find the iOS program Update method, used the first way, but later found some problems, they provide the server, need maintenance, the program submitted after the update, because Apple needs to audit, there will be a time lag, the timing is not good grasp. Backstage to find the relevant documents of Apple, finally found.
Http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

Implementation mechanism:

#define APP_URL @ "Http://itunes.apple.com/lookup?id= your program's AppID"

Asiformdatarequest *formrequst = [asiformdatarequest requestwithurl:[nsurl urlwithstring:app_url];


Request network data, the approximate data returned are as follows, and there are a lot of other data, we intercept the key.

{
Resultcount = 1;
Results = (
{
ArtistID = Developer ID;
artistname = developer Name;
Price = 0;
isgamecenterenabled = 0;
kind = software;
LANGUAGECODESISO2A = (
En
);
Trackcensoredname = review name;
Trackcontentrating = rating;
TrackID = Application ID;
TrackName = Application Name ";
Trackviewurl = Application Introduction URL;
Userratingcount = user Rating;
Userratingcountforcurrentversion = 1;
Version = revision number;
Wrappertype = software;
}
);
}

The key message after obtaining this data is the "version" and the "Trackviewurl" program address. You can then compare it to the version of the local program.




The above build corresponds to the "Bundle version" field in the Info.plist file for debugging purposes, that is, the internal debug version number, which is not displayed on the AppStore

Version corresponds to the "Bundle versions string, short" field in the Info.plist file, which is the real version number, shown on the AppStore. As a result of the previous study, the Internet to check information, there are many people always confuse these two, I also tangled for a while, hereby explain, for memory.

Get the latest version number for AppStore
NSString *newversion = [rightdic objectforkey:@ "version"];

Get the address of the application
NSString *newurl = [rightdic objectforkey:@ "Trackviewurl"];

Get the version number of the local program
Nsdictionary *localdic =[[nsbundle Mainbundle] infodictionary];
NSString *localversion =[localdic objectforkey:@ "cfbundleshortversionstring"];

Cclog (@ "AppStore version number:%@ local version number is:%@", newversion,localversion);

The following is a comparison, the two version number is consistent to decide whether to update, simple, so slightly. There is a need to contact the message.

"Go" iOS program automatically detects the implementation of the update--a good idea

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.