美文网首页
iOS 检查App版本更新

iOS 检查App版本更新

作者: BlueBar | 来源:发表于2022-06-20 09:57 被阅读0次
http://itunes.apple.com/lookup?id=xxx

{
    "resultCount": 1,
    "results": [
        {
            "screenshotUrls": [
                "https://is2-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/81/9b/37/819b37fb-bff4-a5d5-ef0a-1a78a1475e5e/0fd6342e-be1b-43be-ac4d-a7f54cfa9085_0_APP_IPHONE_55_0.png/392x696bb.png",
                "https://is1-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/9a/9e/28/9a9e28f1-688a-bbd4-f2e9-d1caa5991d6e/66fdfb80-5569-4946-8abb-6b620f51176b_1_APP_IPHONE_55_1.png/392x696bb.png",
                "https://is3-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/37/77/69/37776922-1e6c-18ff-b56a-826dea3c7502/e5c27084-9986-465e-836b-e07b0dfd85e0_2_APP_IPHONE_55_2.png/392x696bb.png",
                "https://is5-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/a0/5d/8b/a05d8be9-f549-9b3c-719f-f467468d9941/4ae607a6-f1a3-4f71-8712-16345a01ca52_3_APP_IPHONE_55_3.png/392x696bb.png",
                "https://is5-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/73/f4/02/73f40209-255f-c525-432c-1c19e9bfb090/84e0e8f7-baf0-42af-8272-188a19a22744_4_APP_IPHONE_55_4.png/392x696bb.png"
            ],
            "ipadScreenshotUrls": [
                "https://is1-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/fe/e2/b2/fee2b25c-3992-9f45-456f-6ffef1a68e89/9c1ef6a1-9dbd-4c66-b616-fe49c44a4feb_0_APP_IPAD_PRO_129_0.jpg/576x768bb.jpg",
                "https://is4-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/fb/8c/b2/fb8cb22a-7c8c-c96c-7d30-c9c0c778bdf6/0c1051ad-d2c4-4851-8e52-179bb038682f_1_APP_IPAD_PRO_129_1.jpg/576x768bb.jpg",
                "https://is4-ssl.mzstatic.com/image/thumb/PurpleSource125/v4/c8/59/be/c859be15-1e5e-54a3-55f3-ed9d54f8a6ea/91e2950a-3f77-48aa-a264-0ce6815a3c1c_2_APP_IPAD_PRO_129_2.jpg/576x768bb.jpg",
                "https://is1-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/02/a2/0b/02a20bdb-acdf-7b8d-a659-fb84162af8e2/dbb4cb96-4b40-4a5e-a025-a71c3d59cb65_3_APP_IPAD_PRO_129_3.png/576x768bb.png"
            ],
            "appletvScreenshotUrls": [],
            "artworkUrl60": "https://is2-ssl.mzstatic.com/image/thumb/Purple112/v4/29/5d/bb/295dbb09-b3ba-60a3-7ba7-509941df7a95/AppIcon-0-0-1x_U007emarketing-0-0-0-4-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/60x60bb.jpg",
            "artworkUrl512": "https://is2-ssl.mzstatic.com/image/thumb/Purple112/v4/29/5d/bb/295dbb09-b3ba-60a3-7ba7-509941df7a95/AppIcon-0-0-1x_U007emarketing-0-0-0-4-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x512bb.jpg",
            "artworkUrl100": "https://is2-ssl.mzstatic.com/image/thumb/Purple112/v4/29/5d/bb/295dbb09-b3ba-60a3-7ba7-509941df7a95/AppIcon-0-0-1x_U007emarketing-0-0-0-4-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.jpg",
            "artistViewUrl": "https://apps.apple.com/us/developer/wechat/id614694882?uo=4",
            "features": [
                "iosUniversal"
            ],
            "supportedDevices": [
                "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",
                "iPad75-iPad75",
                "iPad76-iPad76",
                "iPhoneXS-iPhoneXS",
                "iPhoneXSMax-iPhoneXSMax",
                "iPhoneXR-iPhoneXR",
                "iPad812-iPad812",
                "iPad834-iPad834",
                "iPad856-iPad856",
                "iPad878-iPad878",
                "Watch4-Watch4",
                "iPadMini5-iPadMini5",
                "iPadMini5Cellular-iPadMini5Cellular",
                "iPadAir3-iPadAir3",
                "iPadAir3Cellular-iPadAir3Cellular",
                "iPodTouchSeventhGen-iPodTouchSeventhGen",
                "iPhone11-iPhone11",
                "iPhone11Pro-iPhone11Pro",
                "iPadSeventhGen-iPadSeventhGen",
                "iPadSeventhGenCellular-iPadSeventhGenCellular",
                "iPhone11ProMax-iPhone11ProMax",
                "iPhoneSESecondGen-iPhoneSESecondGen",
                "iPadProSecondGen-iPadProSecondGen",
                "iPadProSecondGenCellular-iPadProSecondGenCellular",
                "iPadProFourthGen-iPadProFourthGen",
                "iPadProFourthGenCellular-iPadProFourthGenCellular",
                "iPhone12Mini-iPhone12Mini",
                "iPhone12-iPhone12",
                "iPhone12Pro-iPhone12Pro",
                "iPhone12ProMax-iPhone12ProMax",
                "iPadAir4-iPadAir4",
                "iPadAir4Cellular-iPadAir4Cellular",
                "iPadEighthGen-iPadEighthGen",
                "iPadEighthGenCellular-iPadEighthGenCellular",
                "iPadProThirdGen-iPadProThirdGen",
                "iPadProThirdGenCellular-iPadProThirdGenCellular",
                "iPadProFifthGen-iPadProFifthGen",
                "iPadProFifthGenCellular-iPadProFifthGenCellular",
                "iPhone13Pro-iPhone13Pro",
                "iPhone13ProMax-iPhone13ProMax",
                "iPhone13Mini-iPhone13Mini",
                "iPhone13-iPhone13",
                "iPadMiniSixthGen-iPadMiniSixthGen",
                "iPadMiniSixthGenCellular-iPadMiniSixthGenCellular",
                "iPadNinthGen-iPadNinthGen",
                "iPadNinthGenCellular-iPadNinthGenCellular",
                "iPhoneSEThirdGen-iPhoneSEThirdGen",
                "iPadAirFifthGen-iPadAirFifthGen",
                "iPadAirFifthGenCellular-iPadAirFifthGenCellular"
            ],
            "advisories": [
                "Frequent/Intense Mature/Suggestive Themes"
            ],
            "isGameCenterEnabled": false,
            "kind": "software",
            "minimumOsVersion": "12.0",
            "trackCensoredName": "WeChat",
            "languageCodesISO2A": [
                "AR",
                "EN",
                "FR",
                "DE",
                "ID",
                "IT",
                "JA",
                "KO",
                "MS",
                "PT",
                "RU",
                "ZH",
                "ES",
                "TH",
                "ZH",
                "TR",
                "VI"
            ],
            "fileSizeBytes": "509075456",
            "sellerUrl": "http://www.wechat.com",
            "formattedPrice": "Free",
            "contentAdvisoryRating": "17+",
            "averageUserRatingForCurrentVersion": 4.1471999999999997754684954998083412647247314453125,
            "userRatingCountForCurrentVersion": 65311,
            "averageUserRating": 4.1471999999999997754684954998083412647247314453125,
            "trackViewUrl": "https://apps.apple.com/us/app/wechat/id414478124?uo=4",
            "trackContentRating": "17+",
            "bundleId": "com.tencent.xin",
            "trackId": 414478124,
            "trackName": "WeChat",
            "releaseDate": "2011-01-21T01:32:15Z",
            "genreIds": [
                "6005",
                "6007"
            ],
            "primaryGenreName": "Social Networking",
            "isVppDeviceBasedLicensingEnabled": true,
            "sellerName": "Tencent Technology (Shenzhen) Company Limited",
            "currentVersionReleaseDate": "2022-05-30T02:42:34Z",
            "releaseNotes": "What's New:\n- “Easy Mode” can be enabled to display clearer and larger text and buttons.\n\nRecent Updates:\n- Bug fixes and improvements.",
            "primaryGenreId": 6005,
            "currency": "USD",
            "version": "8.0.23",
            "wrapperType": "software",
            "description": "WeChat is more than a messaging and social media app – it is a lifestyle for one billion users across the world. Chat and make calls with friends, read news and use local services in Official Accounts and Mini Programs, play games with friends, enjoy mobile payment features with WeChat Pay, and much more.\n\nWhy do one billion people use WeChat?\n• MORE WAYS TO CHAT: Message friends using text, photo, voice, video, location sharing, and more. Create group chats with up to 500 members.\n• VOICE & VIDEO CALLS: High-quality voice and video calls to anywhere in the world. Make group video calls with up to 9 people.\n• REAL-TIME LOCATION: Not good at explaining directions? Share your real-time location with the tap of a button.\n• MOMENTS: Never forget your favorite moments. Post photos, videos, and more to share with friends on your personal Moments stream.\n• TIME CAPSULE (NEW!): Share glimpses of your day. Record short videos to post in your Time Capsule before they disappear in 24 hours.\n• STICKER GALLERY: Browse thousands of fun, animated stickers to help express yourself in chats, including stickers with your favorite cartoon and movie characters.\n• CUSTOM STICKERS (NEW!): Make chatting more unique with custom stickers and selfie stickers.\n• OFFICIAL ACCOUNTS: Tons of accounts to follow with original content and news for your reading pleasure.\n• MINI PROGRAMS: Countless third-party services all within the WeChat app that don’t require additional installation, saving you precious phone storage and time. \n• TOP STORIES: See the latest articles your friends are reading and discover all kinds of interesting content.\n• GAMES: Have fun and compete with friends in a huge selection of WeChat Mini Games and Tencent Games (available in select regions).\n• WECHAT PAY: Enjoy the convenience of world-leading mobile payment features with WeChat Pay and Wallet (available in select regions).\n• WECHAT OUT: Make calls to mobile phones and landlines around the globe at super low rates (only available in select regions).\n• WERUN: Use Healthkit and Health app data to sync your step count on WeRun, where you can compete against friends with daily step rankings. Enable WeRun in “Settings” > “General” > “Plug-ins”.\n• LANGUAGE SUPPORT: Localized in 20 different languages and can translate friends' messages and Moments posts.\n• BETTER PRIVACY: Giving you the highest level of control over your privacy, WeChat is the only messaging app to be certified by TRUSTe.\n• EASY MODE: Clearer and larger text and buttons for better readability.",
            "artistId": 614694882,
            "artistName": "WeChat",
            "genres": [
                "Social Networking",
                "Productivity"
            ],
            "price": 0.00,
            "userRatingCount": 65311
        }
    ]
}

+ (void)checkVersionWithAppId:(NSString *)appId{
    NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",appId]];
    [[[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSDictionary * dataDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
        NSArray *results = dataDic[@"results"];
        if (results && results.count > 0) {
            NSDictionary *response = results.firstObject;
            NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; // 软件的当前版本
            NSString *lastestVersion = response[@"version"]; // AppStore 上软件的最新版本
            if (currentVersion && lastestVersion && ![YHelper isLastestVersion:currentVersion compare:lastestVersion]) {
                NSString * releaseNotes = response[@"releaseNotes"]; // 新版本更新内容
                NSString * alertContent = [NSString stringWithFormat:@"%@\n\n是否前往 AppStore 更新版本?",releaseNotes];
                // 给出提示是否前往 AppStore 更新
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"检测到有版本更新" message:alertContent preferredStyle:UIAlertControllerStyleAlert];
                [alert addAction:[UIAlertAction actionWithTitle:@"前往" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                    NSString *trackViewUrl = response[@"trackViewUrl"]; // AppStore 上软件的地址
                    if (trackViewUrl) {
                        NSURL *appStoreURL = [NSURL URLWithString:trackViewUrl];
                        if ([[UIApplication sharedApplication] canOpenURL:appStoreURL]) {
                            [[UIApplication sharedApplication] openURL:appStoreURL options:@{} completionHandler:nil];
                        }
                    }
                }]];
                [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
                [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
            }
        }
    }] resume];
}
/// 判断是否最新版本号(大于或等于为最新)
+ (BOOL)isLastestVersion:(NSString *)currentVersion compare:(NSString *)lastestVersion {
    if (currentVersion && lastestVersion) {
        // 拆分成数组
        NSMutableArray *currentItems = [[currentVersion componentsSeparatedByString:@"."] mutableCopy];
        NSMutableArray *lastestItems = [[lastestVersion componentsSeparatedByString:@"."] mutableCopy];
        // 如果数量不一样补0
        NSInteger currentCount = currentItems.count;
        NSInteger lastestCount = lastestItems.count;
        if (currentCount != lastestCount) {
            NSInteger count = labs(currentCount - lastestCount); // 取绝对值
            for (int i = 0; i < count; ++i) {
                if (currentCount > lastestCount) {
                    [lastestItems addObject:@"0"];
                } else {
                    [currentItems addObject:@"0"];
                }
            }
        }
        // 依次比较
        BOOL isLastest = YES;
        for (int i = 0; i < currentItems.count; ++i) {
            NSString *currentItem = currentItems[i];
            NSString *lastestItem = lastestItems[i];
            if (currentItem.integerValue != lastestItem.integerValue) {
                isLastest = currentItem.integerValue > lastestItem.integerValue;
                break;
            }
        }
        return isLastest;
    }
    return NO;
}

相关文章

  • iOS 检查App版本更新

    可以通过 iTunes 接口检查 App 版本更新,接口为: 请求返回数很多,其中重要信息如下: 然后通过当前Ap...

  • iOS APP检查版本更新

    iOS程序自动提示更新的实现方案大致分为两种:第一种,自己服务器提供一个接口,告知相关app的当前版本,是否需要更...

  • iOS APP检查版本更新

    在开发中,我们可能会遇到这样的需求,当AppStore中有新版本需要更新迭代,用户在点开APP的时候弹出提示框提醒...

  • iOS 检查App版本更新

  • 苹果审核被拒原因

    1.应用内包含检查更新内容 iOS 应用的版本更新必须通过 App Store 进行,自身 App 内不能包含提示...

  • iOS版本更新

    iOS APP版本 更新

  • ionic2实现APP自动更新

    app版本更新可以在应用的设置里面检查版本进行更新或者进入app后自动检查更新。我这里实现的是自动检查更新。 第一...

  • APP检查版本更新

    一、检测更新 二 、UIAlertViewDelegate代理

  • App版本检查更新

    之前都是通过后台的api来判断是否需要弹窗提醒用户更新App,但是会有一个问题,我这边发了新版本之后,没有及时对接...

  • iOS检测版本更新

    利用iTunes接口检查App版本更新

网友评论

      本文标题:iOS 检查App版本更新

      本文链接:https://www.haomeiwen.com/subject/ukadvrtx.html