我们在上传ipa想要安装的时候必须要通过plist文件去下载,并且还要遵循 itms-services协议。
意思就是,第一步我们要生成一个plist文件,
第二步生成一个html文件,用来指向plist文件
这是生成好的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>http://192.168.192.198:8186llk9_60070_60070/218/218_llk9_60070.apk</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.juefeng.lq</string>
<key>bundle-version</key>
<string>1.0.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>连连看9</string>
</dict>
</dict>
</array>
</dict>
</plist>
生成plist文件的方法
/**
* 生成plist文件
*
* @return
*/
public String createPlist(CGame game, String packageName, String filePath,
Logger log) {
log.info("====开始创建plist文件====");
// 这个地址应该是创建的服务器地址,在这里用生成到本地磁盘地址
File file = new File(SubConfig.PLIST_PATH);
if (!file.exists()) {
file.mkdirs();
}
file = new File(SubConfig.PLIST_PATH + game.getId() + "/");
if (!file.exists()) {
file.mkdirs();
}
// 生成的plist路径名称
final String PLIST_PATH = SubConfig.PLIST_PATH + game.getId() + "/"
+ packageName + ".plist";
File plistFile = new File(PLIST_PATH);
if (!plistFile.exists()) {
try {
plistFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
String plist = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n"
+ "<dict>\n"
+ "<key>items</key>\n"
+ "<array>\n"
+ "<dict>\n"
+ "<key>assets</key>\n"
+ "<array>\n"
+ "<dict>\n"
+ "<key>kind</key>\n"
+ "<string>software-package</string>\n"
+ "<key>url</key>\n"
// 你之前所上传的ipa文件路径
+ "<string>" + filePath
+ "</string>\n"
+ "</dict>\n"
+ "</array>\n"
+ "<key>metadata</key>\n"
+ "<dict>\n"
+ "<key>bundle-identifier</key>\n"
// 这个是开发者账号用户名,也可以为空,为空安装时看不到图标,完成之后可以看到
+ "<string>com.juefeng.lq</string>\n"
+ "<key>bundle-version</key>\n" + "<string>1.0.0</string>\n"
+ "<key>kind</key>\n" + "<string>software</string>\n"
+ "<key>title</key>\n" + "<string>" + game.getName()
+ "</string>\n" + "</dict>\n" + "</dict>\n" + "</array>\n"
+ "</dict>\n" + "</plist>";
try {
FileOutputStream output = new FileOutputStream(plistFile);
OutputStreamWriter writer;
writer = new OutputStreamWriter(output, "UTF-8");
writer.write(plist);
writer.close();
output.close();
} catch (Exception e) {
log.info("====创建plist文件异常:" + e.getMessage());
}
log.info("====成功创建plist文件====");
return PLIST_PATH;
}
下载方法
<a title="iPhone" href="itms-services://?action=download-manifest&url=https://xxxxx.plist">
Iphone Download</a>
生成的时候注意文件下载路径filePath是上传了ipa的地址。