App版本检查跳转更新

获取最新版本

从自己服务器获取最新版本号

从自己服务器上获取没什么好说的,自家的约定好就行。

从苹果服务器获取最新版本号

获取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的关系不大)

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,951评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,606评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,601评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,478评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,565评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,587评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,590评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,337评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,785评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,096评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,273评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,935评论 5 339
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,578评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,199评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,440评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,163评论 2 366
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,133评论 2 352

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,008评论 25 707
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,087评论 4 62
  • 今天看了一篇短文,分享一下。 多给孩子一些表扬和鼓励,有利于培养孩子良好的道德行为习惯和品质,有利于增强父母对孩子...
    孙彬洋妈妈阅读 140评论 0 0
  • 在我短短20多年的生命中,绝大部分时光都是在无趣,甚至一片惨淡中度过,偶尔发生的转瞬即逝的高光时刻往往还没让我体会...
    东圭阅读 343评论 0 2
  • 上午爬山,下午葛优躺,缓过劲来黄昏骑行散步。
    周湘泉阅读 199评论 0 2