Original address: http://blog.csdn.net/jslsblog/article/details/9932767
There are two ways to determine the version that is applied in iOS:
1. Sync your app version number on your own server, open the program and go to your server to get the version number and the app version number on your phone to compare, then go to AppStore upgrade
2. Get the latest version information on the AppStore via the URL and compare it with the program version number on your phone to determine if you want to upgrade.
The most common is Method 2, the following is the implementation process of Method 2.
The first step is to get the version information of your app on AppStore, the URL you need to use #define APP_URL @ "http://itunes.apple.com/lookup?id=662004496"
(Replacement ID can be), I see a lot of examples on the internet is to get information synchronously, this will block the main thread, I still think asynchronous is better.
[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
- -(void) Checkversion: (nsstring*) AppUrl
- {
- asiformdatarequest* request=[asiformdatarequest Requestwithurl:[nsurl Urlwithstring:appurl];
- [Request setrequestmethod:@"POST"];
- [Request Setdelegate:self];
- [Request startasynchronous];
- }
Return results are required using JSON parsing
[CPP]View Plaincopy
- -(void) requestfinished: (ASIHTTPRequest *) Request
- {
- nsdictionary* Resultdic=[request.responsedata Jsonvalue];
- nsarray* Infoarray = [resultdic objectforkey:@"Results"];
- if (infoarray.count>0) {
- nsdictionary* releaseinfo =[infoarray objectatindex:0];
- nsstring* appstoreversion = [releaseinfo objectforkey:@"version"];
- Nsdictionary *infodic = [[NSBundle mainbundle] infodictionary];
- NSString *currentversion = [infodic objectforkey:@"cfbundleshortversionstring"];
- if (![ Appstoreversion Isequaltostring:currentversion])
- {
- Trackviewurl = [[NSString alloc] initwithstring:[releaseinfo objectforkey:@"Trackviewurl"];
- nsstring* msg =[releaseinfo objectforkey:@"Releasenotes"];
- uialertview* alertview =[[uialertview alloc] initwithtitle:@"version Upgrade" message:[nsstring stringwithformat:@"%@%@ %@ "@" new version feature: ", MSG, @" \ n is it upgraded? "] delegate:self cancelbuttontitle:@" upgrade later "otherbuttontitles:@"immediately upgrade ", Nil];
- [Alertview show];
- }
- }
- }
Here to talk about the returned JSON data, Aapple returned a lot of data, you see the situation to choose the data you need, the general need is version, one is the application of new features releasenotes, there is a jump address trackviewurl
ArtistID =
Artistname =
Artistviewurl =
artworkUrl100 =
artworkUrl512 =
ARTWORKURL60 =
Bundleid =
Contentadvisoryrating =
Currency =
Description =
features =
Filesizebytes =
Formattedprice =
Genreids =
Genres =
Ipadscreenshoturls =
isgamecenterenabled =
Kind =
LANGUAGECODESISO2A =
Price = 0;
Primarygenreid = 6017;
Primarygenrename =
ReleaseDate = "2013-08-07t07:03:16z";
Releasenotes = "1\u3001\u6dfb\u52a0qq\u8054\u7cfb\u529f\u80fd\n2\u3001\u8bfe\u7a0b\u81ea\u52a8\u64ad\u653e\u65f6 \u6e10\u9690\u8fc7\u5ea6\uff0c\u89c6\u89c9\u6548\u679c\u66f4\u597d\n3\u3001\u4e13\u9898\u6392\u7248\u91cd\ U65b0\u8bbe\u8ba1\uff0c\u4f7f\u4e4b\u66f4\u591a\u7684\u663e\u793a\u4e13\u9898\u4ecb\u7ecd\n4\u3001\u8f6e\u64ad \u56fe\u7247\u52a0\u70b9\u6307\u793a\n5\u3001\u5b66\u9662\u4ecb\u7ecd\u53d8\u6210\u5bcc\u6587\u672c\uff0c\ U53ef\u4ee5\u6d4f\u89c8\u5230\u56fe\u7247\u63cf\u8ff0\n6\u3001\u4fee\u6539\u4e00\u4e9bbug ";
Screenshoturls =
Sellername =
Supporteddevices =
Trackcensoredname =
Trackcontentrating =
TrackID =
TrackName =
Trackviewurl = "https://itunes.apple.com/us/app/quan-min-yu-jia-xue-xiao/id662004496?mt=8&uo=4";
Version = "1.0.1";
Wrappertype =
The last step is to click on the upgraded Jump interface
[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
- -(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) Buttonindex
- {
- if (buttonindex==1)
- {
- UIApplication *application = [UIApplication sharedapplication];
- [Application Openurl:[nsurl Urlwithstring:trackviewurl];
- }
- }
You are welcome to publish your comments, suggestions, we learn together.
IOS to determine app version and upgrade tips