App版本檢查跳轉(zhuǎn)更新

獲取最新版本

從自己服務(wù)器獲取最新版本號

從自己服務(wù)器上獲取沒什么好說的抓督,自家的約定好就行。

從蘋果服務(wù)器獲取最新版本號

獲取iTunes上APP的版本號

用 POST 方式發(fā)送請求https://itunes.apple.com/lookup?id=414478124(微信的id)
在瀏覽器上測試會下載一個txt文本邑贴,文本里是返回的json數(shù)據(jù)席里,解析后是

{
    "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現(xiàn)在線上的最新版本號拢驾。

獲取當前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;
    }
}

跳轉(zhuǎn)更新

注意: 下面的跳轉(zhuǎn)鏈接要看好奖磁,因為有可能會調(diào)到iTunes而不是AppStore。跳轉(zhuǎn)到iTunes的后果就是里面不是更新按鈕而是打開按鈕繁疤,點擊打開按鈕又返回到了app...這就違背了檢查更新的初衷咖为。

//跳轉(zhuǎn)到 iTunes 
NSURL *url1 = [NSURL URLWithString:@"itms://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
//跳轉(zhuǎn)到 AppStore
NSURL *url2 = [NSURL URLWithString:@"itms-apps://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
//跳轉(zhuǎn)到 AppStore
NSURL *url3 = [NSURL URLWithString:@"https://itunes.apple.com/cn/app/idxxxxxxxx?mt=8"];
[[UIApplication sharedApplication] openURL:url2];

參數(shù)解釋:

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,就有可能出現(xiàn)不同類別的內(nèi)容躁染,但是名字相同鸣哀,例如某專輯的名字和某個app的名字重合。這時mt就起作用了吞彤。
ls代表link special我衬,當查詢的類型為某首歌曲時,不定義ls饰恕,默認指向歌曲的專輯低飒,定義后直接進入該歌曲并試播。(貌似是這樣懂盐,apple的論壇里看到的褥赊,跟app的關(guān)系不大)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市莉恼,隨后出現(xiàn)的幾起案子拌喉,更是在濱河造成了極大的恐慌,老刑警劉巖俐银,帶你破解...
    沈念sama閱讀 212,718評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件尿背,死亡現(xiàn)場離奇詭異,居然都是意外死亡捶惜,警方通過查閱死者的電腦和手機田藐,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評論 3 385
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來吱七,“玉大人汽久,你說我怎么就攤上這事∮徊停” “怎么了景醇?”我有些...
    開封第一講書人閱讀 158,207評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長吝岭。 經(jīng)常有香客問我三痰,道長,這世上最難降的妖魔是什么窜管? 我笑而不...
    開封第一講書人閱讀 56,755評論 1 284
  • 正文 為了忘掉前任散劫,我火速辦了婚禮,結(jié)果婚禮上幕帆,老公的妹妹穿的比我還像新娘获搏。我一直安慰自己,他們只是感情好蜓肆,可當我...
    茶點故事閱讀 65,862評論 6 386
  • 文/花漫 我一把揭開白布颜凯。 她就那樣靜靜地躺著谋币,像睡著了一般。 火紅的嫁衣襯著肌膚如雪症概。 梳的紋絲不亂的頭發(fā)上蕾额,一...
    開封第一講書人閱讀 50,050評論 1 291
  • 那天,我揣著相機與錄音彼城,去河邊找鬼诅蝶。 笑死,一個胖子當著我的面吹牛募壕,可吹牛的內(nèi)容都是我干的调炬。 我是一名探鬼主播,決...
    沈念sama閱讀 39,136評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼舱馅,長吁一口氣:“原來是場噩夢啊……” “哼缰泡!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起代嗤,我...
    開封第一講書人閱讀 37,882評論 0 268
  • 序言:老撾萬榮一對情侶失蹤棘钞,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后干毅,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體宜猜,經(jīng)...
    沈念sama閱讀 44,330評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,651評論 2 327
  • 正文 我和宋清朗相戀三年硝逢,在試婚紗的時候發(fā)現(xiàn)自己被綠了姨拥。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,789評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡渠鸽,死狀恐怖叫乌,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情拱绑,我是刑警寧澤综芥,帶...
    沈念sama閱讀 34,477評論 4 333
  • 正文 年R本政府宣布,位于F島的核電站猎拨,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏屠阻。R本人自食惡果不足惜红省,卻給世界環(huán)境...
    茶點故事閱讀 40,135評論 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望国觉。 院中可真熱鬧吧恃,春花似錦、人聲如沸麻诀。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,864評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至呻率,卻和暖如春硬毕,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背礼仗。 一陣腳步聲響...
    開封第一講書人閱讀 32,099評論 1 267
  • 我被黑心中介騙來泰國打工吐咳, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人元践。 一個月前我還...
    沈念sama閱讀 46,598評論 2 362
  • 正文 我出身青樓韭脊,卻偏偏與公主長得像,于是被迫代替她去往敵國和親单旁。 傳聞我的和親對象是個殘疾皇子沪羔,可洞房花燭夜當晚...
    茶點故事閱讀 43,697評論 2 351

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 171,860評論 25 707
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件象浑、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 12,066評論 4 62
  • 今天看了一篇短文任内,分享一下。 多給孩子一些表揚和鼓勵融柬,有利于培養(yǎng)孩子良好的道德行為習(xí)慣和品質(zhì)死嗦,有利于增強父母對孩子...
    孫彬洋媽媽閱讀 138評論 0 0
  • 在我短短20多年的生命中,絕大部分時光都是在無趣粒氧,甚至一片慘淡中度過越除,偶爾發(fā)生的轉(zhuǎn)瞬即逝的高光時刻往往還沒讓我體會...
    東圭閱讀 340評論 0 2
  • 上午爬山,下午葛優(yōu)躺外盯,緩過勁來黃昏騎行散步摘盆。
    周湘泉閱讀 199評論 0 2