http://www.baidufe.com/item/031a86b086d7c0b4514c.html
虽然苹果公司优化过了APP Store,适当加快了APP下载的速度,但是对于中国网民来说,到Apple APP Store中安装或更新APP,都是一件非常痛苦的事情----太慢了!
今天小研究了一下,发现在已越狱的iOS设备上,可以直接通过下载plist的方式,直接安装或更新你的APP。
从前端使用上来讲,最简单来说,就一行代码:
< a
id = "btnInstallApp"
href = "itms-services://?action=download-manifest&url=http://www.ooxxox.com/static/CloudAlbum.plist" > 点击直接安装百度云相册APP </ a > |
当然,通过<a>标签直接打开这么一个协议的地址一般情况下不会有什么问题,但为了不影响页面的正常展示,可以巧妙的使用<iframe>来打开这个链接,因此,再加上下面这一段儿代码即可:
<script> ( function () { var
btnInstallApp = document.getElementById( 'btnInstallApp' ); btnInstallApp.onclick =
function () { var
r = document.createElement( 'iframe' ); r.src =
this .href; r.style.display =
"none" ; document.body.appendChild(r); return
false ; } })(); </script> |
如果你做的是一张二维码,想实现扫描二维码后,不做任何操作即可直接安装APP,那么只需要默认触发一下<a>标签的click事件即可,在上面的代码基础上加上:
// 直接安装 btnInstallApp.click(); |
上面的是结果,下面我们来说前提条件:你得先准备一份儿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 > <!-- 你的APP下载地址 --> < string >http://www.ooxxox.com/static/CloudAlbum_1_0_0_tongbu.ipa</ string > </ dict > < dict > < key >kind</ key > < string >display-image</ string > < key >needs-shine</ key > < true /> < key >url</ key > <!-- 你的APP下载过程中,展示的icon --> < string >http://www.ooxxox.com/static/album.png</ string > </ dict > </ array >< key >metadata</ key > < dict > < key >bundle-identifier</ key > <!-- 你的APP对应的bundle --> < string >com.baidu.album</ string > < key >bundle-version</ key > <!-- 你的APP版本号 --> < string >1.0.0</ string > < key >kind</ key > < string >software</ string > < key >subtitle</ key > <!-- 你的APP名称 --> < string >云相册</ string > < key >title</ key > <!-- 你的APP在下载之前会弹出一个confirm层,让你确认 --> < string >百度云相册1.0版本(需越狱哦,亲)</ string > </ dict > </ dict > </ array > </ dict > </ plist > |