美文网首页
iOS版本更新逻辑

iOS版本更新逻辑

作者: 里克尔梅西 | 来源:发表于2020-06-09 17:35 被阅读0次

一、系统支持自动更新

首先iOS系统中是支持APP的自动更新的,可以开关选择

二、APP内部提示更新

若用户没有选择打开自动更新,择APP中提示更新。可以在用户进入APP首页后进行提示,具体逻辑如下

  • 请求Apple Store上的版本信息
  • 与本地version版本号进行对比
  • 进行跳转到Apple store下载页面
1、请求Apple store上的版本信息
- (void)getAppleStoreVersionInfo:(void(^)(NSString *version, NSString *releaseNotes))successBlock {
    NSInteger appid = @"Apple store上的Appid";
    NSString *urlString = [NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%li",appid];
    [WhzxRequest requestGetWithURL:urlString success:^(NSDictionary * _Nullable resultDictionary, NSURLResponse * _Nullable response) {
        NSString *newVersion = [resultDictionary[@"results"]firstObject][@"version"];
        NSString *releaseNotes = [resultDictionary[@"results"]firstObject][@"releaseNotes"];
        if (successBlock) {
            successBlock(newVersion, releaseNotes);
        }
    } failure:^(NSError * _Nullable error) {
        
    }];
}

得到了线上的版本号、版本更新等信息,具体的信息如下表

//resultCount = 1;
//results =     (
//            {
//        advisories =             (
//        );
//        appletvScreenshotUrls =             (
//        );
//        artistId = 1480665421;
//        artistName = "Jiangxi Yizhi Zhixing Automotive Operations Ltd.";
//        artistViewUrl = "https://apps.apple.com/cn/developer/jiangxi-yizhi-zhixing-automotive-operations-ltd/id1480665421?uo=4";
//        artworkUrl100 = "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/41/05/d0/4105d026-a20a-6125-77f6-4587f190161b/source/100x100bb.jpg";
//        artworkUrl512 = "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/41/05/d0/4105d026-a20a-6125-77f6-4587f190161b/source/512x512bb.jpg";
//        artworkUrl60 = "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/41/05/d0/4105d026-a20a-6125-77f6-4587f190161b/source/60x60bb.jpg";
//        averageUserRating = "2.6875";
//        averageUserRatingForCurrentVersion = "2.6875";
//        bundleId = "com.YTTimeRent.027hb";
//        contentAdvisoryRating = "4+";
//        currency = CNY;
//        currentVersionReleaseDate = "2020-01-07T22:20:33Z";
//        description = "\U4f17\U9a7e\U79df\U8f66\U4e13\U6ce8\U4e8e\U65b0\U80fd\U6e90\U6c7d\U8f66\U7684\U5206\U65f6\U79df\U8d41\Uff0c\U81f4\U529b\U4e8e\U901a\U8fc7\U7535\U52a8\U6c7d\U8f66\U5171\U4eab\U6765\U89e3\U51b3\U57ce\U5e02\U51fa\U884c\U96be\U9898\Uff0c\U4ee5\U79fb\U52a8\U4e92\U8054\U7f51\U4e3a\U57fa\U7840\Uff0c\U7ed3\U5408\U5404\U9879\U804c\U80fd\U6280\U672f\Uff0c\U6765\U5b9e\U73b0\U7528\U6237\U5feb\U901f\U627e\U8f66\Uff0cAPP\U5f00\U95e8\U5173\U95e8\Uff0c\U8fd8\U8f66\U7684\U5168\U7a0b\U81ea\U52a8\U5316\U3002\U6309\U7167\U65f6\U95f4\U7684\U8ba1\U8d39\U65b9\U5f0f\Uff0c\U4e3a\U7528\U6237\U63d0\U4f9b\U7eff\U8272\U3001\U7ecf\U6d4e\U3001\U4fbf\U6377\U7684\U51fa\U884c\U89e3\U51b3\U65b9\U6848\U3002";
//        features =             (
//        );
//        fileSizeBytes = 75225088;
//        formattedPrice = "\U514d\U8d39";
//        genreIds =             (
//            6003
//        );
//        genres =             (
//            "\U65c5\U6e38"
//        );
//        ipadScreenshotUrls =             (
//        );
//        isGameCenterEnabled = 0;
//        isVppDeviceBasedLicensingEnabled = 1;
//        kind = software;
//        languageCodesISO2A =             (
//            ZH
//        );
//        minimumOsVersion = "8.0";
//        price = 0;
//        primaryGenreId = 6003;
//        primaryGenreName = Travel;
//        releaseDate = "2017-02-03T17:20:52Z";
//        releaseNotes = "\U4fee\U590d\U5df2\U77e5bug";
//        screenshotUrls =             (
//            "https://is5-ssl.mzstatic.com/image/thumb/Purple113/v4/01/11/70/01117005-0aee-0f79-610d-c6514f18de4a/pr_source.png/392x696bb.png",
//            "https://is3-ssl.mzstatic.com/image/thumb/Purple113/v4/c4/a5/23/c4a52311-5229-8a62-527a-84ccd1671e6a/pr_source.png/392x696bb.png",
//            "https://is2-ssl.mzstatic.com/image/thumb/Purple123/v4/3f/01/2e/3f012e4e-9209-80ff-85f8-b0d9b7f30be0/pr_source.png/392x696bb.png",
//            "https://is1-ssl.mzstatic.com/image/thumb/Purple113/v4/bb/ec/07/bbec07ce-a013-5b18-1d9d-f323143f6f4c/pr_source.png/392x696bb.png"
//        );
//        sellerName = "Jiangxi Yizhi Zhixing Automotive Operations Ltd.";
//        sellerUrl = "http://www.027hb.cn/";
//        supportedDevices =             (
//            "iPadAir3-iPadAir3",
//            "iPadProSecondGen-iPadProSecondGen",
//            "iPhone6sPlus-iPhone6sPlus",
//            "iPad856-iPad856",
//            "iPhone6Plus-iPhone6Plus",
//            "iPadMini5-iPadMini5",
//            "iPadMini4Cellular-iPadMini4Cellular",
//            "iPhone5c-iPhone5c",
//            "iPadMini3Cellular-iPadMini3Cellular",
//            "iPadThirdGen-iPadThirdGen",
//            "iPadMini-iPadMini",
//            "iPhone6-iPhone6",
//            "iPad878-iPad878",
//            "iPhoneXSMax-iPhoneXSMax",
//            "iPadProCellular-iPadProCellular",
//            "iPhoneXS-iPhoneXS",
//            "iPadProFourthGenCellular-iPadProFourthGenCellular",
//            "iPhone7-iPhone7",
//            "iPhone7Plus-iPhone7Plus",
//            "iPadThirdGen4G-iPadThirdGen4G",
//            "iPad71-iPad71",
//            "iPadAirCellular-iPadAirCellular",
//            "iPad612-iPad612",
//            "iPhone6s-iPhone6s",
//            "iPhone5s-iPhone5s",
//            "iPadMini5Cellular-iPadMini5Cellular",
//            "iPadAir2-iPadAir2",
//            "iPadFourthGen4G-iPadFourthGen4G",
//            "iPad74-iPad74",
//            "iPhoneX-iPhoneX",
//            "iPhone4S-iPhone4S",
//            "iPadPro97Cellular-iPadPro97Cellular",
//            "iPadAir2Cellular-iPadAir2Cellular",
//            "iPadSeventhGenCellular-iPadSeventhGenCellular",
//            "iPadMini3-iPadMini3",
//            "iPhone11-iPhone11",
//            "iPadMiniRetina-iPadMiniRetina",
//            "iPad23G-iPad23G",
//            "iPhoneXR-iPhoneXR",
//            "iPad834-iPad834",
//            "iPad611-iPad611",
//            "iPad75-iPad75",
//            "iPad2Wifi-iPad2Wifi",
//            "iPadPro97-iPadPro97",
//            "iPadProSecondGenCellular-iPadProSecondGenCellular",
//            "iPhone8Plus-iPhone8Plus",
//            "iPadSeventhGen-iPadSeventhGen",
//            "iPodTouchFifthGen-iPodTouchFifthGen",
//            "iPhone8-iPhone8",
//            "iPad812-iPad812",
//            "iPhone5-iPhone5",
//            "iPadFourthGen-iPadFourthGen",
//            "iPhone11ProMax-iPhone11ProMax",
//            "iPodTouchSixthGen-iPodTouchSixthGen",
//            "iPadMini4-iPadMini4",
//            "iPadAir-iPadAir",
//            "iPodTouchSeventhGen-iPodTouchSeventhGen",
//            "iPad73-iPad73",
//            "iPadProFourthGen-iPadProFourthGen",
//            "iPhone11Pro-iPhone11Pro",
//            "iPhoneSESecondGen-iPhoneSESecondGen",
//            "iPad76-iPad76",
//            "iPadMini4G-iPadMini4G",
//            "iPadAir3Cellular-iPadAir3Cellular",
//            "iPhoneSE-iPhoneSE",
//            "iPadMiniRetinaCellular-iPadMiniRetinaCellular",
//            "iPadPro-iPadPro",
//            "iPad72-iPad72"
//        );
//        trackCensoredName = "\U4f17\U9a7e\U79df\U8f66";
//        trackContentRating = "4+";
//        trackId = 1197227551;
//        trackName = "\U4f17\U9a7e\U79df\U8f66";
//        trackViewUrl = "https://apps.apple.com/cn/app/%E4%BC%97%E9%A9%BE%E7%A7%9F%E8%BD%A6/id1197227551?uo=4";
//        userRatingCount = 16;
//        userRatingCountForCurrentVersion = 16;
//        version = "2.4.1";
//        wrapperType = software;
//    }
2、与本地版本号进行对比

获取本地版本号

+ (NSString *)getVersionNumber {
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    return version;
}

判断版本对比

        //判断当前版本和Apple store版本
        if ([appCurrentVersion compare:appStoreVersion options:NSNumericSearch] == NSOrderedAscending) {
            [self showVersionUpdateViewWithInfoDic:releaseNotes];
        }
3、进行跳转到Apple store下载页面
 NSURL *url = [NSURL URLWithString:AppleStoreURL];
    //前往苹果商店更新
 [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];

参考文章:
https://blog.csdn.net/coderMy/article/details/52887050
https://www.jianshu.com/p/f762788f5761

相关文章

  • iOS版本更新逻辑

    一、系统支持自动更新 首先iOS系统中是支持APP的自动更新的,可以开关选择 二、APP内部提示更新 若用户没有选...

  • iOS版本更新

    iOS APP版本 更新

  • iOS 上传AppStore 被拒汇总

    (1)、苹果要求版本更新必须使用iOS版本更新内置更新机制。 4. Design: Preamble Design...

  • iOS版本更新

    1、获取当前版本 NSString *current_version = [[[NSBundle mainBund...

  • iOS 版本更新

    获取本机版本号 NSDictionary *localDic = [[NSBundle mainBundle] i...

  • iOS版本更新

    版本更新 #pragma mark -检查版本更新 - (void)checkNewVersion { // NS...

  • iOS 版本更新

    众所周知苹果拒绝任何带有版本更新的提示出现在页面中,因此我们通过接口获取,处理是否显示更新提示。 1.判断版本号 ...

  • iOS 版本更新

    1.获取本地版本信息 2.获取App Store版本信息 3.新旧版本对比 代码: 请求的基类中获取App Sto...

  • iOS版本更新

    最近,应项目需求,简单写了一个版本更新的提示,有需要的码友可以去下载看看,实现起来比较简单。 效果图 首先是请求a...

  • iOS版本更新

    一、获取app线上版本苹果提供网址:https://itunes.apple.com/lookup网址所需参数:i...

网友评论

      本文标题:iOS版本更新逻辑

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