Cordova配置IOS企业版热更新IVersion插件

IOS企业版版本应用的更新下载不同于个人版本,无需访问应用商店进行更新。可使用插件iVersion检查版本更新。https://github.com/nicklockwood/iVersion

更新原理

引入插件后的App,首先访问配置的远程version.plist文件获取到最新的版本号和版本更新信息,然后会和本地的版本号作比较。如果本地版本号小于远程版本号,app会弹窗提示是否更新,即访问配置的远程下载地址,下载安装更新。

操作步骤

  1. 服务器放置xxx.plist文件 ex:https://xxxx.xxxx.com/IOS/xxt.plist。
  2. 服务器放置一份version.plist文件。描述的是各个版本的更新信息。
  3. Cordova使用iVersion配置远程version.plist文件地址和App的远程下载地址。
  4. XCode打包发布可自动更新的ipa包,并将包放至服务器可访问目录

具体操作

一、准备plist文件。文件名为:xxt.plist。放到服务器(http://xxxxx/xxt/IOS/xxt.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://xxxxx/xxt/IOS/XXX.ipa</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>display-image</string>
					<key>url</key>
					<string>https://xxxxx/xxt/IOS/logo_57x57.png</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>full-size-image</string>
					<key>url</key>
					<string>https://xxxxx/xxt/IOS/logo_512x512.png</string>
				</dict>
			</array>
			<key>metadata</key>
			<dict>
				<key>bundle-identifier</key>
				<string>com.xxxxx.xxx</string>
				<key>bundle-version</key>
				<string>1.0.5</string>
				<key>kind</key>
				<string>software</string>
				<key>title</key>
				<string>XXX</string>
			</dict>
		</dict>
	</array>
</dict>
</plist>

二、XCode修改app版本信息
Xcode修改app版本信息

三、准备versions.plist文件。放到http://xxx.xx.com/ios/versions.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>1.0.5</key>
    <string>优化用户体验</string>
</dict>
</plist>

四、客户端引入iVersion插件。

  1. 访问https://github.com/nicklockwood/iVersion/tree/master/iVersion,将该目录下的文件放置到项目的classes目录下
    如图
  2. AppDelegate.m文件中didFinishLaunchingWithOptions方法中以下代码
iVersion *iv = [iVersion sharedInstance];
    iv.updateURL = [NSURL URLWithString:@"itms-services://?action=download-manifest&url=https://XXX.XXXXX.com/achivements/XXX.plist"];
    iv.remoteVersionsPlistURL = @"https://XXX.XXXXX.com/achivements/versions.plist";

  1. iVersion.m中可修改弹框按钮的文本
- (NSString *)downloadButtonLabel
{
    return _downloadButtonLabel ?: [self localizedStringForKey:iVersionDownloadButtonKey withDefault:@"现在安装"];
}

- (NSString *)remindButtonLabel
{
    return _remindButtonLabel ?: [self localizedStringForKey:iVersionRemindButtonKey withDefault:@"稍后提醒"];
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章