Method for dynamically generating ios plist

  ios

Freemarker template

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

Download page

ReferencesTwo-dimensional code app download scheme

Pit

For this plist interface, if it is not a PathVariable parameter but a RequestParam, the request for plist cannot be sent through itms-services, and then the parameters are changed to PathVariable.

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

doc