企业级发布版本更新功能的实现主要分两步:
1、获取服务器端plist文件中的版本号
2、与当前程序的版本号进行比较,如果服务器端版本号高则更新。
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"发现新版本,是否立即更新" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *updateAction = [UIAlertAction actionWithTitle:@"更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *downloadUrl = [NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@", appDownloadURL];
NSURL *appurl = [NSURL URLWithString:downloadUrl];
[[UIApplication sharedApplication] openURL:appurl];
}];
UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"忽略" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:updateAction];
[alertController addAction:cancleAction];
[self presentViewController:alertController animated:YES completion:nil];
});