[IOS] How do I query the information of published apps from appstore?

Source: Internet
Author: User

If we need to automatically update the version of the app, we need to obtain the version information of the current running program and the latest version released in the appstore.

The version information of the currently running program, which can be obtained in mainbundle:

[CPP]
View plaincopyprint?
  1. Nsdictionary * infodict = [[nsbundle mainbundle] infodictionary];
  2. Nsstring * CurrentVersion = [infodict objectforkey: @ "cfbundleversion"];

The retrieval of the latest version released in the appstore is a little complicated. There are two solutions with the same idea:

1. Store the latest version information on a server and query the server whenever necessary;

Second: query the appstore as needed;

Here I will introduce the second method: query application information from the appstore, including the author, version, and page address of the app.

For good English, refer to the Apple documentation: www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

The procedure is as follows:

1. Send the request in post mode:

Http://itunes.apple.com/search? Term = your application name & entity = Software

The more accurate method is to search by app id:

Http://itunes.apple.com/lookup? Id = the ID of your application

2. parse the required data from the obtained response data. Because the information obtained from the appstore query is in JSON format, it must be parsed. The raw data obtained after parsing is as follows:

[HTML]
View plaincopyprint?
  1. {
  2. Resultcount = 1;
  3. Results = (
  4. {
  5. Artistid = 301724683;
  6. Artistname = Citigroup;
  7. Artistviewurl = "http://itunes.apple.com/us/artist/citibank/id301724683? Uo = 4 ";
  8. Artworkurl100 = "http://a5.mzstatic.com/us/r1000/117/Purple/a1/85/a9/mzl.hvwnfdkw.png ";
  9. Artworkurl512 = "http://a5.mzstatic.com/us/r1000/117/Purple/a1/85/a9/mzl.hvwnfdkw.png ";
  10. Artworkurl60 = "http://a2.mzstatic.com/us/r1000/099/Purple/67/86/7e/mzi.utfdvrgy.png ";
  11. Averageuserrating = "3.5 ";
  12. Averageuserratingforcurrentversion = 5;
  13. Contentadvisoryrating = "4 + ";
  14. Currency = USD;
  15. Description = "description of you app .";
  16. Features = (
  17. Iosuniversal
  18. );
  19. Filesizebytes = 4141195;
  20. Genreids = (
  21. 6015
  22. );
  23. Genres = (
  24. Finance
  25. );
  26. Ipadscreenshoturls = (
  27. "Http://a1.mzstatic.com/us/r1000/095/Purple/e0/a6/17/mzl.pbbxcjzt.1024x1024-65.jpg ",
  28. Http://a3.mzstatic.com/us/r1000/036/Purple/cc/14/98/mzl.dyairego.1024x1024-65.jpg"
  29. );
  30. Isgamecenterenabled = 0;
  31. Kind = software;
  32. Languagecodesiso2a = (
  33. En
  34. );
  35. Price = 0;
  36. Primarygenreid = 6015;
  37. Primarygenrename = finance;
  38. Releasedate = "2011-01-24t06: 14: 35z ";
  39. Releasenotes = "* view Real-Time Streaming prices for u. s. treasuries \ n * Open and save your Citi research in your favorite pdf reader and Library such as ibooks \ n * search for your Favorite Videos ";
  40. Screenshoturls = (
  41. "Http://a3.mzstatic.com/us/r1000/066/Purple/17/51/fb/mzl.zywiavgn.png ",
  42. Http://a5.mzstatic.com/us/r1000/026/Purple/73/85/97/mzl.csmdtndk.png"
  43. );
  44. Sellername = "Citibank, N. .";
  45. Sellerurl = "http ://";
  46. Supporteddevices = (
  47. All
  48. );
  49. Trackcensoredname = "Citi velocity ";
  50. Trackcontentrating = "4 + ";
  51. TrackID = 414697122;
  52. Trackname = "Citi velocity ";
  53. Trackviewurl = "http://itunes.apple.com/us/app/citi-velocity/id414697122? Mt = 8 & uo = 4 ";
  54. Userratingcount = 5;
  55. Userratingcountforcurrentversion = 1;
  56. Version = "1.4 ";
  57. Wrappertype = software;
  58. }
  59. );
  60. }

Then obtain the results array. The Code is as follows:

[CPP]
View plaincopyprint?
  1. Nsdictionary * jsondata = [datapayload jsonvalue];
  2. Nsarray * infoarray = [jsondata objectforkey: @ "Results"];
  3. Nsdictionary * releaseinfo = [infoarray objectatindex: 0];
  4. Nsstring * latestversion = [releaseinfo objectforkey: @ "version"];
  5. Nsstring * trackviewurl = [releaseinfo objectforkey: @ "trackviewurl"];

If you copy the actual address of trackviewurl and open it in the browser, the introduction page of your application in appstore will be displayed. Of course, we can also call safari in the code to open it.

[CPP]
View plaincopyprint?
  1. Uiapplication * Application = [uiapplication sharedapplication];
  2. [Application Openurl: [nsurl urlwithstring: trackviewurl];

Reprinted: http://blog.csdn.net/kesalin/article/details/6605934

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.