最简单企业证书部署应用!In-House改进版!免HTTPS!
2017-04-04 22:41
513 查看
https://segmentfault.com/a/1190000002991014
网上搜索
如果有做过
是因为对配置文件不了解,出错了也不知道错在哪里。
没有条件部署
最简单的方式(上传
安装页面引入这个
在安装按钮的位置调用
参数说明
实现逻辑:客户端根据自己的软件需求,传参到服务器,服务器动态生成
这样,就不需要每个新的应用都去配置一次
我现在提供的动态
服务器PHP实现:从URL中截获参数,使用参数拼接好
有兴趣的话可以看看这个项目,
https://github.com/qzs21/iComic
利用
iOS平台发布应用,想绕过
AppStore,最好的方式就是
In-House发布了(由于越狱用户覆盖不全,一般不考虑越狱方式)。
网上搜索
In-House的教程也很多,怎么申请企业证书,怎么对
ipa包进行大包签名我就不再复述,文章最后附了两个链接,不了解的童鞋可以看一看。
如果有做过
In-House部署,应该知道,需要准备一个描述应用信息的
*.plist文件上传到服务器,并且从
iOS7及以后版本,此文件必须部署在
HTTPS服务器上才能正常安装。这一步非常容易出错不能成功部署。
出错原因:
签名错误或者打包方式不对。是因为对配置文件不了解,出错了也不知道错在哪里。
没有条件部署
HTTPS服务器
最简单的方式(上传ipa
包到http
服务器,调用一个js
方法)
安装页面引入这个JS
<script src="http://iosinstall.sinaapp.com/plist/ios-install.js"></script>
在安装按钮的位置调用
openInstallURL方法,可以使用任意HTML标签!
<div onclick="openInstallURL({ 'title' : '我是App标题', 'ipa' : 'http://www.xxx.com/app.ipa', 'version' : '1.0', 'ident' : 'cn.xxx.xxx', 'icon' : ''});">点击安装</div>
参数说明
参数 | 说明 | 备注 |
---|---|---|
title | 标题 | Safari弹出安装提示时提示的标题 |
ipa | 你猜 | ipa包需要你上传到自己的服务器上,然后将可以下载到这个ipa包的URL填写到这里,可以使用HTTP协议! |
version | 你再猜 | ⚠️iOS9以后,必须跟ipa包上的版本号对应,否则安装到最后会提示失败 |
ident | App唯一标识符 | 你可以在项目配置的Bundle Identifier下看到他 |
icon | 安装加载过程中的图标 | 如果传入空字符串,会有一个默认图标: |
Demo
对HTML不熟悉的同学可以直接用下面的代码,样式已经写好了,将其保存成*.html文件即可
<html> <head> <meta name="generator" content="HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.12), see www.w3.org" /> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>APP测试</title> <link rel="stylesheet" href="http://iosinstall.sinaapp.com/plist/ios-install.css"> <script src="http://iosinstall.sinaapp.com/plist/ios-install.js"></script> </head> <body> <h5 style="text-align: center; color: red; padding: 20px;">⚠️注意!以下安装包仅用于测试!<br/></h5> <install-btn onclick="openInstallURL({ 'title' : '我是标题', 'ipa' : 'http://www.xxx.com/ipa/xxxx.ipa', 'version' : '1.0', 'ident' : 'com.xxx.xxx', 'icon' : ''});">点击我安装</install-btn> </body> </html>
如果你想完全自己提供这些,请看下面的内容。
实现原理
我曾经为了解决In-House部署问题,也走了很多弯路,为了解决
HTTPS的问题,使用私有证书,利用
Dropbox的HTTPS服务,又或是使用Github的HTTPS服务,这些方式都是可行的,但是都有不同程度的麻烦,于是有了今天这个帖子。
实现逻辑:客户端根据自己的软件需求,传参到服务器,服务器动态生成
*.plist,因为
iOS会检测
*.plist的URL,不能带有参数,所以将参数用
Base64加密后加到URL路径中,服务器截取路径中的参数部分解密获得参数。由于路径变化的特殊性,需要配置好服务器的重定向。
这样,就不需要每个新的应用都去配置一次
*.plist文件了!
我现在提供的动态
*.plist运行在新浪云稳定快速,可以放心使用!
js实现的逻辑:收集参数,将参数加密成Base64字符串,插入到访问URL里面。
// http://iosinstall.sinaapp.com/plist/ios-install.js var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var base64DecodeChars = new Array( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); // Base64编码的方法 function base64encode(str) { var out, i, len; var c1, c2, c3; len = str.length; i = 0; out = ""; while(i < len) { c1 = str.charCodeAt(i++) & 0xff; if(i == len) { out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt((c1 & 0x3) << 4); out += "=="; break; } c2 = str.charCodeAt(i++); if(i == len) { out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); out += base64EncodeChars.charAt((c2 & 0xF) << 2); out += "="; break; } c3 = str.charCodeAt(i++); out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); out += base64EncodeChars.charAt(c3 & 0x3F); } return out; } // 计算hash值 var I64BIT_TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-'.split(''); function hash(input){ var hash = 5381; var i = input.length - 1; if(typeof input == 'string'){ for (; i > -1; i--) hash += (hash << 5) + input.charCodeAt(i); } else{ for (; i > -1; i--) hash += (hash << 5) + input[i]; } var value = hash & 0x7FFFFFFF; var retValue = ''; do{ retValue += I64BIT_TABLE[value & 0x3F]; } while(value >>= 6); return retValue; } /** Demo: var info = { 'title' : '我是标题', // app name 'ipa' : 'http://www.xxx.com/ipa/xxx.ipa', // ipa url 'version' : '1.0', 'ident' : 'cn.xxx.xxx', 'icon' : '' // icon url }; openInstallURL(info); */ function openInstallURL(info) { if (info.ident == null || info.ident.length == 0) { info.ident = 'cn.ineva.cn'; } if (info.icon == null || info.icon.length == 0) { info.icon = 'http://iosinstall.sinaapp.com/plist/ios-install.png'; } if (info.version == null || info.version.length == 0) { info.version = '1.0.0'; } var json = JSON.stringify(info) var base64String = base64encode(encodeURI(json)).replace(/\=/g, ""); var fileName = hash(base64String) var s = 128; var count = Math.ceil( base64String.length / s); var path = ""; // 因为新浪对链接文件名和目录的长度有限制,json数据,使用`/`分隔 for (var i = 0; i < count; i++) { var l = s; if (i == count - 1) { l = base64String.length - i * s; } path += "/" + base64String.substr( i * s, l); } var url = 'https://iosinstall.sinaapp.com/plist' + path + "/" + fileName + ".plist"; window.self.location = 'itms-services://?action=download-manifest&url=' + url; }
服务器PHP实现:从URL中截获参数,使用参数拼接好
*.plist文件内容,将拼接好的内容当文件返回。
<?php $pathItems = explode('/', $_SERVER["REQUEST_URI"]); if ( count($pathItems) < 4 ) { return; } $base64Data = ""; $fileName = "ios-install.plist"; for ( $i = 2; $i < count($pathItems); $i++ ) { if ( $i == count($pathItems) - 1 ) { $fileName = $pathItems[$i]; } else { $base64Data .= $pathItems[$i]; } } $jsonString = urldecode(base64_decode($base64Data)); $obj = json_decode($jsonString); $ipa = $obj->ipa; $icon = $obj->icon; $ident = $obj->ident; $version = $obj->version; $title = $obj->title; $data = '<?xml version="1.0" encoding="UTF-8"?> <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>'.$ipa.'</string> </dict> <dict> <key>kind</key> <string>display-image</string> <key>needs-shine</key> <true/> <key>url</key> <string>'.$icon.'</string> </dict> </array> <key>metadata</key> <dict> <key>bundle-identifier</key> <string>'.$ident.'</string> <key>bundle-version</key> <string>'.$version.'</string> <key>kind</key> <string>software</string> <key>title</key> <string>'.$title.'</string> </dict> </dict> </array> </dict> </plist>'; $file_size = strlen($data); ob_clean(); header("Content-type:application/octet-stream"); header("Server:nginx/1.4.4"); header("Content-type:text/plain"); header("Accept-Ranges:bytes"); header("Accept-Length:".$file_size); header("Content-Disposition: attachment; filename=".$fileName); echo $data;
其他方式发布(适合开源项目)
我开发的一个看韩国漫画的项目,使用手机上的Safari打开链接就可以安装:http://qzs21.github.io/iComic/有兴趣的话可以看看这个项目,
代码和安装包发布部署都是使用Github(master分支下面是项目代码,gh-pages分支就是安装页面的代码):
https://github.com/qzs21/iComic
相关推荐
非常详尽的In-House部署教程:http://blog.csdn.net/yangxt/article/details/7998762
利用
Github的
HTTPS服务部署:http://my.oschina.net/qixiaobo025/blog/321050
相关文章推荐
- 【iOS开发】企业版证书($299)In-House方式发布指南
- 【iOS开发】企业版证书($299)In-House方式发布指南
- 使用 Cerbot 部署 Let's Encrypt免费证书 简单 升级 http 到 https 申请单域名ssl证书
- 企业版证书($299)In-House方式发布指南
- 解决企业In-House安装APP需HTTPS支持的问题
- iOS企业版证书($299)In-House方式发布指南
- 【iOS开发】企业版证书($299)In-House方式发布指南 (转)
- 【iOS开发】企业版证书($299)In-House方式发布指南
- ios开发企业版plist发布In-House简单记录
- 【iOS开发】企业版证书($299)In-House方式发布指南
- IOS 企业版证书($299)In-House方式发布指南
- 【iOS开发】企业版证书($299)In-House方式发布指南
- 企业版证书($299)In-House方式发布指南
- IOS企业App应用的安装及https证书生成
- iOS企业版证书($299)In-House方式发布指南
- 解决企业In-House安装APP需HTTPS支持的问题(转载)
- 打包测试 之 企业证书的打包过程以及注意事项(in-house方式)
- 企业版证书($299)In-House方式发布指南
- 【iOS开发】企业版证书($299)In-House方式发布指南
- 【iOS开发】企业版证书($299)In-House方式发布指南