目前我们一般采用的是使用itms-services 来实现下载(升级)。
itms-services 的地址是:
itms-services://?action=download-manifest&url=你得plist存放地址(要是https)
由网上可知
plist file模板
<?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>${ipaDownloadUrl}</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>${identifier}</string>
<key>bundle-version</key>
<string>${version}</string>
<key>kind</key>
<string>software</string>
<key>subtitle</key>
<string>${subtitle}</string>
<key>title</key>
<string>${title}</string>
</dict>
</dict>
</array>
</dict>
</plist>
如果有自建服务器的话,可以在服务器代码中直接生成plist
在java controller 中:
/**
* 制作plist文件
* */
@PostMapping("/app/getPlistFile")
public void getPlistFile(@RequestBody JSONObject jsonObject, HttpServletRequest request, HttpServletResponse response) {
// 获取嵌入的字段
String appName = param.getString("appName");
String ipaURL = param.getString("ipaURL");
String bundleID = param.getString("bundleID");
String iconURL = param.getString("iconURL");
String content = PlistUtil.generateContent("plist.ftl",data);
// 直接构建文本返回参数
try {
File newFileName = new File(localFileName);
response.setContentType("application/force-download");
appName = new String(appName.getBytes("UTF-8"), "iso-8859-1");
response.setHeader("Content-Disposition", "attachment;filename=" + appName+".plist");
response.setHeader("Content-Length", "" + newFileName.length());
byte[] buffer = new byte[1024];
OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(new File(localFileName));
BufferedInputStream bis = new BufferedInputStream(fis);
int i = bis.read(buffer);
while (i != -1) {
os.write(buffer);
i = bis.read(buffer);
}
try {
bis.close();
} catch (Exception e) {
}
try {
fis.close();
} catch (Exception e) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
二维码生成
草料二维码
通过草料二维码即可生成二维码
通过github的服务地址实现下载
直接将plist文件直接上传到git仓库中,将URL直接放置在itms-services 链接中即可实现