iOS 版本更新

2017/09/27 iOS

版本更新

@interface MLVersionUpdateModel : NSObject

@property (nonatomic, copy) NSString *version; //版本号

@property (nonatomic, copy) NSString *context; //版本更新内容

/** 检测版本更新 */
+ (void)checkNewVersion;

@end

+ (void)checkNewVersion {
    [MLAPIManager postWithUrl:API_Version_Update params:@{} success:^(id response) {
        MLVersionUpdateModel *model = [MLVersionUpdateModel mj_objectWithKeyValues:response[@"data"]];
        NSString *version = model.version;
        // 如果当前版本小于接口版本, 则更新(例如:1.0.0 和 1.1.0)
        if ([APP_VERSION compare:version options:NSNumericSearch] != NSOrderedAscending)
        {
            NSLog(@"不需要更新");
            return ;
        }
        [UIAlertController alertWithTitle:@"版本更新" message:model.context cancel:^(UIAlertAction *action) {

        } other:^(UIAlertAction *action) {
            //跳转到手机APP商店
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:APPLE_Store_URLStr]];
        }];
    } fail:nil];
}

Search

    Table of Contents