1. 通过info.plist文件中的bundle version中获取:
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDic);
NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
// ....
2. 通过苹果服务器获取
利用 iTunes Search API 获取 app 信息
其中一种方法是根据 app 的 id 来查找:
http://itunes.apple.com/lookup?id=appId (appId为应用 id)
或者
http://itunes.apple.com/lookup?bundleId=bundleId (bundleId为应用的 BundleId)
回来补坑
如果你的应用是在全世界范围内销售的话, 用上面的是没问题的
但是,如果仅仅是在部分地区, 比如只在中国商店提供下载,就需要在路径是加上国家的缩写cn
.
http://itunes.apple.com/cn/lookup?id=appId (appId为应用 id)
同理, 利用 bundleId 获取也是一样的, 路径上需要加上地区cn
.
http://itunes.apple.com/cn/lookup?bundleId=bundleId (bundleId为应用的 BundleId)
否则你将会得到一个results : []
的结果
返回的json数据
结构
{
"resultCount": 1,
"results": [
{
"ipadScreenshotUrls": [
"http://a2.mzstatic.com/us/r30/Purple62/v4/31/3b/dd/313bdd53-bf40-4d07-6e08-11e926575348/sc552x414.jpeg",
"http://a4.mzstatic.com/us/r30/Purple71/v4/20/a2/72/20a27207-ce2d-1069-cc4d-fb550c089d91/sc552x414.jpeg",
"http://a2.mzstatic.com/us/r30/Purple71/v4/49/7e/af/497eaf80-e64f-8896-c033-25fb90b0f4be/sc552x414.jpeg",
"http://a5.mzstatic.com/us/r30/Purple62/v4/9a/db/3b/9adb3b9c-3ba3-29e1-db43-628d16dcac91/sc552x414.jpeg",
"http://a5.mzstatic.com/us/r30/Purple71/v4/19/01/af/1901af49-4678-e985-d967-9a796636c4d6/sc552x414.jpeg"
],
"appletvScreenshotUrls": [],
"artworkUrl60": "http://is5.mzstatic.com/image/thumb/Purple111/v4/e5/59/03/e55903e7-f8de-c582-7729-f918147018c1/source/60x60bb.jpg",
"artworkUrl512": "http://is5.mzstatic.com/image/thumb/Purple111/v4/e5/59/03/e55903e7-f8de-c582-7729-f918147018c1/source/512x512bb.jpg",
"artworkUrl100": "http://is5.mzstatic.com/image/thumb/Purple111/v4/e5/59/03/e55903e7-f8de-c582-7729-f918147018c1/source/100x100bb.jpg",
"artistViewUrl": "https://itunes.apple.com/us/developer/yelp/id284910353?uo=4",
"features": [
"iosUniversal"
],
"kind": "software",
"supportedDevices": [
"iPad2Wifi-iPad2Wifi",
"iPad23G-iPad23G",
"iPhone4S-iPhone4S",
"iPadThirdGen-iPadThirdGen",
"iPadThirdGen4G-iPadThirdGen4G",
"iPhone5-iPhone5",
"iPodTouchFifthGen-iPodTouchFifthGen",
"iPadFourthGen-iPadFourthGen",
"iPadFourthGen4G-iPadFourthGen4G",
"iPadMini-iPadMini",
"iPadMini4G-iPadMini4G",
"iPhone5c-iPhone5c",
"iPhone5s-iPhone5s",
"iPadAir-iPadAir",
"iPadAirCellular-iPadAirCellular",
"iPadMiniRetina-iPadMiniRetina",
"iPadMiniRetinaCellular-iPadMiniRetinaCellular",
"iPhone6-iPhone6",
"iPhone6Plus-iPhone6Plus",
"iPadAir2-iPadAir2",
"iPadAir2Cellular-iPadAir2Cellular",
"iPadMini3-iPadMini3",
"iPadMini3Cellular-iPadMini3Cellular",
"iPodTouchSixthGen-iPodTouchSixthGen",
"iPhone6s-iPhone6s",
"iPhone6sPlus-iPhone6sPlus",
"iPadMini4-iPadMini4",
"iPadMini4Cellular-iPadMini4Cellular",
"iPadPro-iPadPro",
"iPadProCellular-iPadProCellular",
"iPadPro97-iPadPro97",
"iPadPro97Cellular-iPadPro97Cellular",
"iPhoneSE-iPhoneSE",
"iPhone7-iPhone7",
"iPhone7Plus-iPhone7Plus",
"iPad611-iPad611",
"iPad612-iPad612"
],
"screenshotUrls": [
"http://a1.mzstatic.com/us/r30/Purple62/v4/e9/66/bf/e966bfa0-78c6-739e-a1b2-1d37ea53432f/screen696x696.jpeg",
"http://a1.mzstatic.com/us/r30/Purple62/v4/45/cf/71/45cf71de-77d9-363a-8100-ade36f9a3a40/screen696x696.jpeg",
"http://a5.mzstatic.com/us/r30/Purple62/v4/a3/af/ad/a3afadb5-fde5-3ec5-169e-b5131672a28c/screen696x696.jpeg",
"http://a2.mzstatic.com/us/r30/Purple62/v4/38/fe/a5/38fea567-c499-45a6-a69b-dadc34614ff8/screen696x696.jpeg"
],
"advisories": [
"Infrequent/Mild Sexual Content and Nudity",
"Infrequent/Mild Profanity or Crude Humor",
"Infrequent/Mild Mature/Suggestive Themes",
"Infrequent/Mild Alcohol, Tobacco, or Drug Use or References"
],
"isGameCenterEnabled": false,
"languageCodesISO2A": [
"CS",
"DA",
"NL",
"EN",
"FI",
"FR",
"DE",
"IT",
"JA",
"MS",
"NB",
"PL",
"PT",
"ZH",
"ES",
"SV",
"ZH",
"TR"
],
"fileSizeBytes": "169932800",
"trackCensoredName": "Yelp - Nearby Restaurants, Shopping & Services",
"contentAdvisoryRating": "12+",
"averageUserRatingForCurrentVersion": 4.5,
"userRatingCountForCurrentVersion": 1692,
"trackViewUrl": "https://itunes.apple.com/us/app/yelp-nearby-restaurants-shopping-services/id284910350?mt=8&uo=4",
"trackContentRating": "12+",
"currency": "USD",
"wrapperType": "software",
"version": "11.12.0",
"description": "Yelp has over 100 million reviews of businesses worldwide and is available for iPhone, iPad, and Apple Watch.\n\nWhether you’re looking for a pizzeria that just opened or a coffee shop nearby, Yelp is your local guide to finding the perfect place to eat, shop, drink, relax and play.\n\nYelp features:\n\nFind Restaurants\n• Find the newest and hottest restaurants in your area\n• Make reservations, pick up food and order for delivery, all from your phone\n• Filter restaurant search results by price, location and more\n\nSearch for Nearby Businesses\n• Discover great local businesses\n• Read millions of reviews by the Yelp community\n• Find great deals offered by local businesses\n\nSearch Filters \n• Filter your search results by neighborhood, distance, rating, price and hours of operation\n• Look up addresses and phone numbers, call a business or make reservations directly from the app\n\nOther Features\n• Read expert user reviews and browse through beautiful photos of each business\n• Write and read reviews, check-in to local businesses, upload photos and add tips for other Yelp users\n\nFind local restaurants, read expert customer reviews and start searching for businesses near you with Yelp.\n\nNeed Help? Contact Yelp at https://www.yelp-support.com/?l=en_US\nNote: Continued use of GPS running can dramatically decrease battery life.",
"artistId": 284910353,
"artistName": "Yelp",
"genres": [
"Travel",
"Food & Drink"
],
"price": 0,
"formattedPrice": "Free",
"trackId": 284910350,
"trackName": "Yelp - Nearby Restaurants, Shopping & Services",
"bundleId": "com.yelp.yelpiphone",
"primaryGenreName": "Travel",
"isVppDeviceBasedLicensingEnabled": true,
"releaseDate": "2008-07-11T07:00:00Z",
"releaseNotes": "Spring’s coming and bugs are coming back in style in the real world, but in the Yelp app they’re going out of style and fast. We fixed a whole bunch.",
"primaryGenreId": 6003,
"genreIds": [
"6003",
"6023"
],
"sellerName": "Yelp, Inc.",
"minimumOsVersion": "8.0",
"currentVersionReleaseDate": "2017-04-05T18:53:21Z",
"averageUserRating": 4,
"userRatingCount": 213622
}
]
}
更详细的文档地址:
https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/