获取最新版本
从自己服务器获取最新版本号
从自己服务器上获取没什么好说的,自家的约定好就行。
从苹果服务器获取最新版本号
获取iTunes上APP的版本号
用 POST 方式发送请求https://itunes.apple.com/lookup?id=414478124
(微信的id)
在浏览器上测试会下载一个txt文本,文本里是返回的json数据,解析后是
{
"resultCount":1,
"results":[
{
"ipadScreenshotUrls":[
"http://is2.mzstatic.com/image/thumb/Purple117/v4/a1/69/ac/a169ac6e-312b-309c-c11a-89ba48a01d39/source/576x768bb.jpg",
"http://is5.mzstatic.com/image/thumb/Purple117/v4/b7/53/6e/b7536e0b-0a6d-ec79-c146-0e29db308817/source/576x768bb.jpg",
"http://is5.mzstatic.com/image/thumb/Purple127/v4/b7/78/80/b77880be-8629-88ab-8e31-1debff900e83/source/576x768bb.jpg",
"http://is1.mzstatic.com/image/thumb/Purple127/v4/66/28/fe/6628fe0d-66f1-e476-d9a2-7828cb32cdcc/source/576x768bb.jpg"
],
"appletvScreenshotUrls":[
],
"artworkUrl60":"http://is1.mzstatic.com/image/thumb/Purple128/v4/58/ae/73/58ae73a0-1bbe-bd36-46e8-38b9e5d0641e/source/60x60bb.jpg",
"artworkUrl512":"http://is1.mzstatic.com/image/thumb/Purple128/v4/58/ae/73/58ae73a0-1bbe-bd36-46e8-38b9e5d0641e/source/512x512bb.jpg",
"artworkUrl100":"http://is1.mzstatic.com/image/thumb/Purple128/v4/58/ae/73/58ae73a0-1bbe-bd36-46e8-38b9e5d0641e/source/100x100bb.jpg",
"artistViewUrl":"https://itunes.apple.com/us/developer/wechat/id614694882?uo=4",
"kind":"software",
"features":[
"iosUniversal"
],
"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",
"iPad71-iPad71",
"iPad72-iPad72",
"iPad73-iPad73",
"iPad74-iPad74",
"iPhone8-iPhone8",
"iPhone8Plus-iPhone8Plus",
"iPhoneX-iPhoneX"
],
"screenshotUrls":[
"http://is5.mzstatic.com/image/thumb/Purple127/v4/23/c0/dd/23c0dde6-f43b-d13b-ff12-f3dd0fc2911d/source/392x696bb.jpg",
"http://is1.mzstatic.com/image/thumb/Purple122/v4/33/fa/38/33fa3803-cbbe-19e2-3225-efda30868629/source/392x696bb.jpg",
"http://is4.mzstatic.com/image/thumb/Purple127/v4/84/94/a5/8494a587-b41d-843a-5f62-245124cf12f7/source/392x696bb.jpg",
"http://is3.mzstatic.com/image/thumb/Purple117/v4/4b/35/22/4b352282-6178-8b3a-94f4-4a20df147ea1/source/392x696bb.jpg",
"http://is4.mzstatic.com/image/thumb/Purple127/v4/43/8c/0a/438c0a11-f8b4-2458-6953-1003b293c7f1/source/392x696bb.jpg"
],
"advisories":[
"Infrequent/Mild Sexual Content and Nudity"
],
"isGameCenterEnabled":false,
"averageUserRatingForCurrentVersion":4.5,
"trackCensoredName":"WeChat",
"languageCodesISO2A":[
"AR",
"ZH",
"EN",
"FR",
"DE",
"HE",
"HI",
"ID",
"IT",
"JA",
"KO",
"MS",
"PL",
"PT",
"RU",
"ZH",
"ES",
"TH",
"ZH",
"TR",
"VI"
],
"fileSizeBytes":"235411456",
"sellerUrl":"http://www.wechat.com",
"contentAdvisoryRating":"12+",
"userRatingCountForCurrentVersion":3578,
"trackViewUrl":"https://itunes.apple.com/us/app/wechat/id414478124?mt=8&uo=4",
"trackContentRating":"12+",
"formattedPrice":"Free",
"sellerName":"Tencent Technology (Shenzhen) Company Limited",
"minimumOsVersion":"8.0",
"genreIds":[
"6005",
"6007"
],
"currentVersionReleaseDate":"2017-12-28T06:20:47Z",
"wrapperType":"software",
"version":"6.6.1",
"description":"WeChat is a messaging and calling app that allows you to easily connect with family & friends across countries. It's the all-in-one communications app for text (SMS/MMS), voice and video calls, Moments, photo sharing, and games.
WHY USE WECHAT:
• MULTIMEDIA MESSAGING: Send video, image, text, and voice messages.
• GROUP CHAT & CALLS: Create group chats with up to 500 people and group video calls up to 9 people.
• FREE VOICE & VIDEO CALLS: High-quality free calls to anywhere in the world.
• WECHAT OUT CALLS: Make calls to landlines and mobile around the globe at low rates (in certain regions only).
• STICKER GALLERY: Hundreds of free, fun, animated stickers to express your feelings from some of your favorite cartoons and movies.
• MOMENTS: Share your best moments on your personal photo stream.
• BETTER PRIVACY: WeChat gives you the highest level of control over your privacy. It's the only messaging app to be certified by TRUSTe.
• MEET NEW FRIENDS: Use “Friend Radar”, “People Nearby” and “Shake” to meet others.
• REALTIME LOCATION: Instead of having to tell others where you are, just use real-time location sharing.
• LANGUAGE SUPPORT: Localized in 20 different languages and can translate messages to any language.
• WeRun-WeChat: Access HealthKit data and challenge friends to beat their scores via the "WeRun-WeChat" Official Account.
• AND MORE: Desktop app, custom wallpapers, custom notifications, and Official Accounts.",
"artistId":614694882,
"artistName":"WeChat",
"genres":[
"Social Networking",
"Productivity"
],
"price":0,
"currency":"USD",
"trackId":414478124,
"trackName":"WeChat",
"bundleId":"com.tencent.xin",
"isVppDeviceBasedLicensingEnabled":true,
"primaryGenreName":"Social Networking",
"releaseDate":"2011-01-21T01:32:15Z",
"releaseNotes":"Latest Updates:
- Notes in Favorites can be saved as an image, making it easier to share to Moments.
- Sent a message with a typo? Recall the message and immediately edit your message.
Recent Updates:
- Compatible with iPhone X
- Edit videos before sending
- Disable alerts for likes or comments to Moments posts
- Search files, photos and links within your chat history
- Information on how group members joined a group now available to group owners
- Preview and edit selected photos before sending them to friends",
"primaryGenreId":6005,
"averageUserRating":4.5,
"userRatingCount":44769
}
]
}
全是iTunes里你提交的信息,当然包括你APP现在线上的最新版本号。
获取当前App版本号
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
对比三段式版本号
+ (BOOL)isNewestVersion:(NSString *)version
{
NSString *currentV = [APPVERSION stringByReplacingOccurrencesOfString:@"." withString:@""];
NSString *onlineV = [version stringByReplacingOccurrencesOfString:@"." withString:@""];
if (onlineV.integerValue > currentV.integerValue) {
return NO;
}else {
return YES;
}
}
跳转更新
注意: 下面的跳转链接要看好,因为有可能会调到iTunes而不是AppStore。跳转到iTunes的后果就是里面不是更新按钮而是打开按钮,点击打开按钮又返回到了app...这就违背了检查更新的初衷。
//跳转到 iTunes
NSURL *url1 = [NSURL URLWithString:@"itms://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
//跳转到 AppStore
NSURL *url2 = [NSURL URLWithString:@"itms-apps://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
//跳转到 AppStore
NSURL *url3 = [NSURL URLWithString:@"https://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
[[UIApplication sharedApplication] openURL:url2];
参数解释:
mt:meta-type 有效值如下
1 Music
2 Podcasts
3 Audiobooks
4 TV Shows
5 Music Videos
6 Movies
7 iPod Games
8 Mobile Software Applications
9 Ringtones
10 iTunes U
11 E-Books
12 Desktop Apps
当链接进行查询时,如果没有定义id,就有可能出现不同类别的内容,但是名字相同,例如某专辑的名字和某个app的名字重合。这时mt就起作用了。
ls代表link special,当查询的类型为某首歌曲时,不定义ls,默认指向歌曲的专辑,定义后直接进入该歌曲并试播。(貌似是这样,apple的论坛里看到的,跟app的关系不大)
网友评论