相关文章推荐
鬼畜的绿豆  ·  Visual Studio 调试系列6 ...·  4 月前    · 
英姿勃勃的课本  ·  Microsoft Entra ...·  8 月前    · 
含蓄的饭盒  ·  Python ...·  1 年前    · 
冷静的米饭  ·  SpringBoot 1.X到2.X ...·  1 年前    · 

版本号的格式:v<主版本号>.<副版本号>.<发布号>
如版本号为2.3.6
1. 我一般把第一位作为大版本号。如出现重大更新,如果用户不更新,这个app都用不下去了。这个时候就要强制用户更新。
2. 第二位作为功能版本号。比如增加了一些新的功能。这个时候通过增加这个版本号,来添加功能。
3. 第三位作为修订版本号。如,上线后出现了一个bug,这个bug需要及时修复,这个时候就增加这个修订版本号。

强制更新:

在出现第一位版本号变化的时候,强制更新。通过appStore上的版本和当前的版本对比。

可选更新:

在非第一位版本号变化的时候,用户可以选择暂时忽略(下次还会出现这个弹窗),跳过(下次打开不出现),或者更新app。

具体看后面代码⤵️

  1. 强制更新
    这里写图片描述
  2. 可选更新
    这里写图片描述

部分代码段

1.获取appstore上的内容

- (void)checkVersion{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager GET:[LGAppInfo appUrlInItunes] parameters:nil progress:nil success:^(NSURLSessionDataTask *task,id responseObject) {
        LGLog(@"%@",responseObject);
        //1.是否请求成功
        if (((NSArray *)responseObject[@"results"]).count<=0) return;
        //2.获取appstore版本号和提示信息
        self.storeVersion = [(NSArray *)responseObject[@"results"] firstObject][@"version"];
          NSString *releaseNotes = [(NSArray *)responseObject[@"results"] firstObject][@"releaseNotes"];
        //3.获取跳过的版本号
        NSString *skipVersion = [[NSUserDefaults standardUserDefaults] valueForKey:skipVersionKey];
        //4.比较版本号
        LGLog(@"%@--%@",self.storeVersion,skipVersion);
        if ([self.storeVersion isEqualToString:skipVersion]) {//如果store和跳过的版本相同
            return;
        }else{
            [self compareCurrentVersion:[LGAppInfo appVersion] withAppStoreVersion:self.storeVersion updateMsg:releaseNotes];
    } failure:nil];

2.比较版本

当前版本号和appstore比较 @param currentVersion 当前版本 @param appStoreVersion appstore上的版本 @param updateMsg 更新内容 - (void)compareCurrentVersion:(NSString *)currentVersion withAppStoreVersion:(NSString *)appStoreVersion updateMsg:(NSString *)updateMsg{ NSMutableArray *currentVersionArray = [[currentVersion componentsSeparatedByString:@"."] mutableCopy]; NSMutableArray *appStoreVersionArray = [[appStoreVersion componentsSeparatedByString:@"."] mutableCopy]; if (!currentVersionArray.count ||!appStoreVersionArray.count) return; //修订版本号 int modifyCount = abs((int)(currentVersionArray.count - appStoreVersionArray.count)); if (currentVersionArray.count > appStoreVersionArray.count) { for (int index = 0; index < modifyCount; index ++) { [appStoreVersionArray addObject:@"0"]; } else if (currentVersionArray.count < appStoreVersionArray.count) { for (int index = 0; index < modifyCount; index ++) { [currentVersionArray addObject:@"0"]; //大版本必须强制更新<及 第一位表示大版本> if ([currentVersionArray.firstObject integerValue] > [appStoreVersionArray.firstObject integerValue]) { //强制更新--- [self showUpdateAlertMust:YES withStoreVersion:appStoreVersion message:updateMsg]; }else{//不需要强制更新 检查后面的版本号,如果比appstore大 则更新 for (int index = 0; index<currentVersionArray.count; index++) { if ([currentVersionArray[index] integerValue]> [appStoreVersionArray[index] integerValue]) { [self showUpdateAlertMust:NO withStoreVersion:appStoreVersion message:updateMsg]; return;

3.跳转界面

打开appstore 执行更新操作 - (void)openAppStoreToUpdate{ LGLog(@"打开到appstore"); NSURL *trackUrl = [NSURL URLWithString:self.trackViewUrl]; if ([LGApplication canOpenURL:trackUrl]) { [[UIApplication sharedApplication] openURL:trackUrl];

在appdelegate.m中,程序唤醒后调用如下:

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[LGCheckVersion shareCheckVersion] checkVersion];

demo地址

https://github.com/LGLee/LGCheckUpdate.git

点个赞送大胸美女一枚

版本号规则版本号的格式:v<主版本号>.<副版本号>.<发布号> 如版本号为2.3.6 1. 我一般把第一位作为大版本号。如出现重大更新,如果用户不更新,这个app都用不下去了。这个时候就要强制用户更新。 2. 第二位作为功能版本号。比如增加了一些新的功能。这个时候通过增加这个版本号,来添加功能。 3. 第三位作为修订版本号。如,上线后出现了一个bug,这个bug需要及时修复,这个时候
刚接触ios开发的童鞋应该会对于app版本号吗有些疑问,因为target不仅仅在summary中有版本号,同样在Info.plist等地方也有版本号码的地方,一头乱码,不知吗?其实xcode在summary中已经将app最基本的设置进行了全面的封装,其余的plist,build setting等地方会跟着summary设置的改变而改变。 一个version,一个build,都是设
要想规避苹果审查,我们需要通过调用数据接口来控制调用app 版本强制更新功能:当苹果在审查的时候,我们可以通过后台数据控制关闭版本强制更新功能,等苹果审核通过以后我通过后台控制打开版本强制更新功能。下面是app 版本强制更新功能实现的代码: AppDelegate.h文件 #import @interface AppDelegate : UIResponder @property (
 //app强制更新     //定义的app的地址     NSString *urld = [NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@  ",@"你的ap 通常iOS系统中是默认设置再wifi状态,且网络状况良好下自己更新应用的. 但是如果用户设置了不自动更新,但是我们的APP出现重要的版本,一定需要用户更新的情况下,就会需要这个功能了. 这个版本更新一般会有两种方式: 1.在自己的服务器上部署上一个文件,写入版本数据,然后app去获取版本数据,与自己的当前版本比对, 提示更新 优点... 第二种:需要服务端交互 每次提交版本/升级前把本地提交给服务端;由服务端控制是否更新: 服务端把最新版本号发给客户端,以及升级的详细信息,升级状态:强制升级、普通升级、已经是最新版本,不需要升级。 //获取本地版本 ...