iOS 判断当前app版本,升级

要获取当前app store上的最新的版本,有两种方法,

一、在某特定的服务器上,发布和存储app最新的版本信息,需要的时候向该服务器请求查询。

二、从app store上查询,可以获取到app的作者,连接,版本等。官方相关文档

https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/


具体步骤如下:
1,用 POST 方式发送请求:
http://itunes.apple.com/search?term=你的应用程序名称&entity=software

更加精准的做法是根据 app 的 id 来查找:
http://itunes.apple.com/lookup?id=你的应用程序的ID

当前运行版本信息可以通过info.plist文件中的bundle version中获取
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
 
 
https://itunes.apple.com/lookup?id=1035259256
 
{
"resultCount": 1
"results": [1]
0:  {
"screenshotUrls": [4]
0:  "http://a2.mzstatic.com/us/r30/Purple69/v4/9f/3c/d5/9f3cd5e2-583c-d6ce-6067-75fd42ba8078/screen1136x1136.jpeg"
1:  "http://a4.mzstatic.com/us/r30/Purple69/v4/d2/6b/ff/d26bffe0-eece-792e-871e-35180e4386ce/screen1136x1136.jpeg"
2:  "http://a3.mzstatic.com/us/r30/Purple4/v4/cb/b1/78/cbb17801-2223-41f1-da37-5e8f280ad58c/screen1136x1136.jpeg"
3:  "http://a5.mzstatic.com/us/r30/Purple69/v4/4d/42/f3/4d42f3da-dd05-a4d5-405b-181dda585ad6/screen1136x1136.jpeg"
-
"ipadScreenshotUrls": [0]
"artworkUrl512": "http://is5.mzstatic.com/image/thumb/Purple49/v4/ca/16/32/ca1632b3-a491-d7eb-b1d1-c120bc80a833/source/512x512bb.jpg"
"artistViewUrl": "https://itunes.apple.com/us/developer/shen-zhen-shi-cai-fu-bao-wang/id1035259255?uo=4"
"artworkUrl60": "http://is5.mzstatic.com/image/thumb/Purple49/v4/ca/16/32/ca1632b3-a491-d7eb-b1d1-c120bc80a833/source/60x60bb.jpg"
"artworkUrl100": "http://is5.mzstatic.com/image/thumb/Purple49/v4/ca/16/32/ca1632b3-a491-d7eb-b1d1-c120bc80a833/source/100x100bb.jpg"
"features": [0]
"kind": "software"
"supportedDevices": [17]
0:  "iPhone4"
1:  "iPad2Wifi"
2:  "iPad23G"
3:  "iPhone4S"
4:  "iPadThirdGen"
5:  "iPadThirdGen4G"
6:  "iPhone5"
7:  "iPodTouchFifthGen"
8:  "iPadFourthGen"
9:  "iPadFourthGen4G"
10:  "iPadMini"
11:  "iPadMini4G"
12:  "iPhone5c"
13:  "iPhone5s"
14:  "iPhone6"
15:  "iPhone6Plus"
16:  "iPodTouchSixthGen"
-
"advisories": [1]
0:  "Unrestricted Web Access"
-
"isGameCenterEnabled": false
"languageCodesISO2A": [2]
0:  "ZH"
1:  "EN"
-
"fileSizeBytes": "18205874"
"sellerUrl": "http://www.qianshenghua.com/"
"trackContentRating": "17+"
"trackCensoredName": "钱生花 - 社区金融,您身边的家庭理财师"
"trackViewUrl": "https://itunes.apple.com/us/app/qian-sheng-hua-she-qu-jin/id1035259256?mt=8&uo=4"
"contentAdvisoryRating": "17+"
"currency": "USD"
"wrapperType": "software"
"version": "1.2.2"
"description": "钱生花(www.qianshenghua.com)是专业互联网金融投资理财机构,平台致力于为广大投资者提供安全、低门槛、高收益的互联网金融服务。作为目前国内最大的社区金融平台,钱生花要求资金雄厚的第三方机构和融资项目推荐机构对平台的融资项目进行逾期回购,让融资项目必须具有一定的信誉、实力和可控的预期。"
"artistId": 1035259255
"artistName": "深圳市彩付宝网络技术有限公司"
"genres": [2]
0:  "Finance"
1:  "Lifestyle"
-
"price": 0
"bundleId": "com.qianshenghua.hehenianMobile"
"trackName": "钱生花 - 社区金融,您身边的家庭理财师"
"trackId": 1035259256
"releaseDate": "2015-09-23T22:37:39Z"
"primaryGenreName": "Finance"
"isVppDeviceBasedLicensingEnabled": true
"genreIds": [2]
0:  "6015"
1:  "6012"
-
"sellerName": "Shenzhen Caifubao Network Technology Co., Ltd."
"currentVersionReleaseDate": "2016-01-29T10:29:40Z"
"releaseNotes": "1、优化体验,我的账户,更多改为原生界面 2、优化APP启动时候卡顿的问题 3、优化加载H5界面的问题 4、优化财富地图"
"primaryGenreId": 6015
"formattedPrice": "Free"
"minimumOsVersion": "7.0"
}-
-
}
trackCensoredName = 审查名称;
trackContentRating = 评级;
trackId = 应用程序 ID;
trackName = 应用程序名称;
trackViewUrl = 应用程序介绍网址;
userRatingCount = 用户评级;
userRatingCountForCurrentVersion = 1;
version = 版本号;
 
 
 
原文地址:https://www.cnblogs.com/dhui69/p/5231656.html