有一個這樣的需求:一些大廠比如:BATDS等,開發的應用很多,有些應用隻是員工使用,隻需要内部分發,不需要上架AppStore。那麼怎麼讓員工通過iPhone下載下傳尼?
這裡就講一下如何不上架AppStore 通過企業證書打包的ipa 企業分發?
首先:蘋果允許用itms-services協定來直接在iphone/ipad上安裝應用程式,我們可以直接生成該協定需要的相關檔案,這樣産品經理和測試都可以直接在裝置上安裝新版的應用。
1. 第一步準備:
-
299$的企業賬号
用于打包,隻有用企業證書打包的ipa才能下載下傳
- 對應的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>https://bsssit.cjh.com/dtap/public/app/ios/VoiceCollection.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://bsssit.cjh.com/dtap/public/app/ios/configFile/audiopro.png</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://bsssit.cjh.com/dtap/public/app/ios/configFile/audiopro.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>title</key>
<string>話術</string>
<key>bundle-version</key>
<string>1.0.0</string>
<key>kind</key>
<string>software</string>
<key>bundle-identifier</key>
<string>com.chj.VoiceCollection</string>
</dict>
</dict>
</array>
</dict>
</plist>
這個我的測試過plist,注意plist 的結構,一定不能搞錯(有同僚搞錯這個檔案,害得我和背景找了2天才搞定)
software-package:url :ttps://bsssit.cjh.com/dtap/public/app/ios/VoiceCollection.ipa (你的ipa的位址)
url:logo圖檔的位址
bundle-identifier:com.xx.xx:(bundleID需要ipa中需要保持一緻)
bundle-version:1.0.0 (CFBundleVersion需要和ipa中的保持一緻)
title:話術 (随便起,用于踴躍alert确認時的提示)
3. IPA安裝包一個
2.部署plist檔案與IPA安裝包
itms-services協定:
itms-services://?action=download-manifest&url=https://********/**/tue_test.plist
部署plist檔案的位址必須是https,不然在iPhone裝置上可能會導緻“無法連接配接到xxx”這樣的提示,導緻安裝失敗。如果沒有https伺服器。可以利用開源中國(http://git.oschina.net/)提供的代碼托管服務,托管一下plist檔案,然後ipa的安裝包和index.html依舊放在自己的伺服器上.itms-services協定後面的url位址,改成在plist檔案在開源中國上的url(注意url結束到.plist為止,後面的那一串參數不要帶,直接手動把http改為https)。
将修改後的plist放到https 的服務、把企業證書打的ipa 上傳到自己的伺服器。
3.下載下傳使用
編寫一個簡單的HTML頁面,手機通過通路這個頁面點選下載下傳安裝
比如:立即下載下傳 的位址就是
itms-services://?action=download-manifest&url=https://.../xxx.plist
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Install</title>
</head>
<body>
<p align=center>
<font size="10">
<a style="color:#69DEDA" href="itms-services://?action=download-manifest&url=https://.../xxx.plist" target="_blank" rel="external nofollow" >立即下載下傳</a>
</font>
</p>
</body>
</html>
- 我們可以看到 “href=” 裡面是指向了 plist 檔案的位址(而不是IPA安裝包的位址)
- 最好還是使用iPhone裝置自帶的Safari浏覽器打開該頁面,點選下載下傳。 上面是Safari 下載下傳,在應用中更新的代碼:有更新時觸發下面的代碼
NSString *scheme = @"itms-services://?action=download-manifest&url=https://.../xxx.plist";
[self openScheme:scheme];
- (void)openScheme:(NSString *)scheme {
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:scheme];
if (@available(iOS 10.0, *)) {
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
NSLog(@"Open %@: %d",scheme,success);
}];
} else {
// Fallback on earlier versions
if ([application canOpenURL:URL]) {
[application openURL:URL];
}
}
}
直接安裝執行個體:(慧眼)
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:@"itms-services://?action=download-manifest&url=https://oss.suning.com/sastore/snapp/upload/app_inner/ios/20190524/cc1c8baa88705aab909e571c435eef81.plist"];
if (@available(iOS 10.0, *)) {
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
NSLog(@"Open %@: %d",scheme,success);
}];
} else {
// Fallback on earlier versions
if ([application canOpenURL:URL]) {
[application openURL:URL];
}
}
借鑒:https://www.jianshu.com/p/4eeddf929b90