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 > |