版本更新管理

单例封装了一个版本更新管理类


UI效果:



+ (instancetype)sharedInstance {

    static UpdateVersionManage *sharedInstance =nil;

    static dispatch_once_t oncePredicate;

    dispatch_once(&oncePredicate, ^{

        sharedInstance = [[self alloc] init];

    });

    return sharedInstance;

}


- (void)setIsHaveIgnoreUP:(BOOL)isHaveIgnoreUP{

    _isHaveIgnoreUP = isHaveIgnoreUP;

}


-(instancetype)init{

    self=[superinit];

    if (self) {

        __weak typeof(self) weakSelf=self;

        self.updateBlock = ^(NSString *currentVersion ,NSString *releaseNotes,NSString *trackUrl, NSString *type){

            __strong typeof(self) strongSelf=weakSelf;

            

            [strongSelf showUpdateViewWith:(NSString *)currentVersionwith:(NSString *)releaseNoteswith:(NSString *)trackUrlwith:type];

            

        };

        

    }

    return self;

}


#pragma mark--版本更新--1表示不需要更新,2选择更新,3强制更新

+(void)checkVersionInController:(UIViewController *)showController{

    

#pragma mark--type --网络请求获得type值,根据业务处理

    NSString *type = @"3";

    if ([typeisEqualToString:@"2"])

    {//有更新,当前版本可用

        if ([UpdateVersionManagesharedInstance].isHaveIgnoreUP ==YES) {

            return ;

        }

        [UpdateVersionManagesharedInstance].showController = showController;

        [UpdateVersionManagesharedInstance].isHaveIgnoreUP =YES;

        if ([UpdateVersionManagesharedInstance].updateBlock) {

            [UpdateVersionManagesharedInstance].updateBlock(@"更新内容",@"优化了哪些内容",@"下载链接",type);

        }

    }

    else if ([typeisEqualToString:@"3"])//强制更新

    {

        [UpdateVersionManagesharedInstance].showController = showController;

        

        if ([UpdateVersionManagesharedInstance].updateBlock) {

            [UpdateVersionManagesharedInstance].updateBlock(@"更新内容",@"优化了哪些内容",@"下载链接",type);

        }

        

    }

    

}


#pragma mark  - 更新界面

-(void)showUpdateViewWith:(NSString *)currentVersion with:(NSString *)releaseNotes with:(NSString *)trackUrl with:(NSString *)type{

    

    if ([typeisEqualToString:@"2"])

    {

        [self showIgnoreUpdateViewWith:currentVersionwith:releaseNotes with:trackUrl];

    }else if ([typeisEqualToString:@"3"])

    {

       [self showMustUpdateViewWith:currentVersionwith:releaseNotes with:trackUrl];

    }

}


-(void)showIgnoreUpdateViewWith:(NSString *)currentVersion with:(NSString *)releaseNotes with:(NSString *)trackUrl{

    UIAlertController *alertController=[UIAlertControlleralertControllerWithTitle:[NSStringstringWithFormat:@"发现新版本%@",currentVersion] message:releaseNotespreferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *action1=[UIAlertActionactionWithTitle:@"下次再说" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {

        

        

    }];

    UIAlertAction *action2=[UIAlertActionactionWithTitle:@"前往更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {

        [[UIApplicationsharedApplication] openURL:[NSURLURLWithString:[trackUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSetURLQueryAllowedCharacterSet]]]];

    }];

    [alertController addAction:action1];

    [alertController addAction:action2];

    if ([UpdateVersionManagesharedInstance].showController) {

         [[UpdateVersionManagesharedInstance].showControllerpresentViewController:alertController animated:YEScompletion:nil];

    }else

    {

        [[UpdateVersionManagegetCurrentVC]presentViewController:alertController animated:YEScompletion:nil];

    }

}


-(void)showMustUpdateViewWith:(NSString *)currentVersion with:(NSString *)releaseNotes with:(NSString *)trackUrl{

    

    UIAlertController *alertController=[UIAlertControlleralertControllerWithTitle:[NSStringstringWithFormat:@"发现新版本%@",currentVersion] message:releaseNotespreferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *action2=[UIAlertActionactionWithTitle:@"前往更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {

        [[UIApplicationsharedApplication] openURL:[NSURLURLWithString:[trackUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSetURLQueryAllowedCharacterSet]]]];

        

    }];

    [alertController addAction:action2];

    if ([UpdateVersionManagesharedInstance].showController) {

        [[UpdateVersionManagesharedInstance].showControllerpresentViewController:alertController animated:YEScompletion:nil];

    }else

    {

        [[UpdateVersionManagegetCurrentVC]presentViewController:alertController animated:YEScompletion:nil];

    }

}



Git地址demo

iOS版本管理


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
yum 包管理器是 CentOS 系统中默认的包管理器,它负责管理系统中的软件包。要更新 yum 包管理器的版本,您可以执行以下步骤: 1. 更新系统软件包。 在更新 yum 包管理器之前,您应该先更新系统中的所有软件包。您可以使用以下命令更新系统软件包: ``` sudo yum update ``` 2. 安装 EPEL 软件源。 EPEL 是一个第三方的软件源,提供了很多 CentOS 官方软件源中没有的软件包。您可以使用以下命令安装 EPEL 软件源: ``` sudo yum install epel-release ``` 3. 安装 yum-utils 工具。 yum-utils 是一个包含了许多 yum 相关工具的软件包。其中包括一个名为 `yum-plugin-versionlock` 的插件,它可以用于锁定特定软件包的版本。您可以使用以下命令安装 yum-utils 工具: ``` sudo yum install yum-utils ``` 4. 更新 yum 包管理器的版本。 您可以使用以下命令更新 yum 包管理器的版本: ``` sudo yum update yum ``` 该命令将会更新 yum 包管理器以及它的所有依赖关系。 5. 锁定 yum 包管理器的版本。 如果您想要锁定 yum 包管理器的版本,以防止它被更新到一个不稳定的版本,可以使用 `yum-plugin-versionlock` 插件。您可以使用以下命令安装 `yum-plugin-versionlock` 插件: ``` sudo yum install yum-plugin-versionlock ``` 安装完成后,您可以使用以下命令锁定 yum 包管理器的版本: ``` sudo yum versionlock add yum ``` 该命令将会锁定 yum 包管理器的版本,以防止它被更新到新的版本。 需要注意的是,更新 yum 包管理器的版本可能会影响系统中已安装的软件包的依赖关系。因此,在更新之前,请仔细检查系统中已安装的软件包及其依赖关系,并确保它们与新版本的 yum 包管理器兼容。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值