freemarker模板
<?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>
controller
@RequestMapping(value = "/plist/{id}",method = RequestMethod.GET)
public void plist(HttpServletResponse response,@PathVariable String id) throws IOException, TemplateException {
Map<String,Object> data = new HashMap<>();
//put variables
//....
//convert to string
String content = FreemarkerUtil.generateContent("plist.ftl",data);
response.setHeader("Content-Type", "application/octet-stream; charset=utf-8");
response.setHeader("Content-Disposition",
"attachment;filename=app.plist");
response.getWriter().write(content.toCharArray());
}
下载页面
坑
对于这个plist的接口,如果不是PathVariable的参数,而是RequestParam这种,通过itms-services无法发送对plist的请求,后来把参数都改为经过PathVariable才可以。
itms-services://?action=download-manifest&url=https://xxxxxx/plist/xxxxx