当前位置:   article > 正文

(0091)iOS开发itms-services协议安装IPA安装包

itms-services

有一个这样的需求:一些大厂比如:BATDS等,开发的应用很多,有些应用只是员工使用,只需要内部分发,不需要上架AppStore。那么怎么让员工通过iPhone下载尼?

这里就讲一下如何不上架AppStore 通过企业证书打包的ipa 企业分发?

首先:苹果允许用itms-services协议来直接在iphone/ipad上安装应用程序,我们可以直接生成该协议需要的相关文件,这样产品经理和测试都可以直接在设备上安装新版的应用。

1. 第一步准备:
  1. 299$的企业账号
    用于打包,只有用企业证书打包的ipa才能下载

  2. 对应的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>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

这个我的测试过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确认时的提示)
  • 1
  • 2
  • 3
  • 4
  • 5

在这里插入图片描述
3. IPA安装包一个

2.部署plist文件与IPA安装包

itms-services协议:

itms-services://?action=download-manifest&url=https://********/**/tue_test.plist
  • 1

部署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">立即下载</a>
          </font>
        </p>
    </body>
</html>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 我们可以看到 “href=” 里面是指向了 plist 文件的地址(而不是IPA安装包的地址)
  • 最好还是使用iPhone设备自带的Safari浏览器打开该页面,点击下载。
    在这里插入图片描述
    上面是Safari 下载,在应用中更新的代码:有更新时触发下面的代码
NSString *scheme = @"itms-services://?action=download-manifest&url=https://.../xxx.plist";
[self openScheme:scheme];
  • 1
  • 2
- (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];
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

直接安装实例:(慧眼)

    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];
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

借鉴:https://www.jianshu.com/p/4eeddf929b90

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/746184
推荐阅读
相关标签
  

闽ICP备14008679号