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());
    }

下载页面

参考二维码app下载方案

对于这个plist的接口,如果不是PathVariable的参数,而是RequestParam这种,通过itms-services无法发送对plist的请求,后来把参数都改为经过PathVariable才可以。

itms-services://?action=download-manifest&url=https://xxxxxx/plist/xxxxx

doc


codecraft
11.9k 声望2k 粉丝

当一个代码的工匠回首往事时,不因虚度年华而悔恨,也不因碌碌无为而羞愧,这样,当他老的时候,可以很自豪告诉世人,我曾经将代码注入生命去打造互联网的浪潮之巅,那是个很疯狂的时代,我在一波波的浪潮上留下...