版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.youkuaiyun.com/weixin_43299553/article/details/83184485
1、首先做好你的企业包。
2、编写plist文件,配置IPA地址(注意必须是https的服务器),并配置到https的服务器上。
如下图
plist文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https:********.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>AppIcon60x60%402x.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.*******</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>****</string>
</dict>
</dict>
</array>
</dict>
3.APP中请求plist文件,判断APP版本跳出弹窗提示更新。
NSOperationQueue * queue = [[NSOperationQueue alloc] init];
[queue addOperation:[NSBlockOperation blockOperationWithBlock:^{
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"这里填写你的plist文件地址"]];
if (dict) {
NSString* newVersion = [[[[dict objectForKey:@"items"] objectAtIndex:0] objectForKey:@"metadata"] objectForKey:@"bundle-version"];
NSString *myVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
if (![newVersion isEqualToString:myVersion]) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"发现新版本,是否前往更新?" message:@"更新说明:....." preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"不了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-services://?action=download-manifest&url=你的plist文件地址"]];
}]];
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alertController animated:YES completion:nil];
}
}else{
NSLog(@"您已经是最新版");
}
}]];
4.本人使用的提示更新 ,你也可以强制更新。
可以做类似应用商店的效果。