mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	https (+1 squashed commit)
Squashed commits: [8a28169] https
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| # react-native-update [](http://badge.fury.io/js/react-native-update) | ||||
|  | ||||
| 本组件是面向 React Native 提供热更新功能的组件,建议结合[Update 服务](http://update.reactnative.cn/)使用。 | ||||
| 本组件是面向 React Native 提供热更新功能的组件,建议结合[Update 服务](https://update.reactnative.cn/)使用。 | ||||
|  | ||||
| ### 最新更新 | ||||
|  | ||||
| @@ -22,11 +22,11 @@ | ||||
|  | ||||
| | React Native 版本 | react-native-update 版本 | | ||||
| | ----------------- | ------------------------ | | ||||
| | 0.26 及以下       | 1.0.x                    | | ||||
| | 0.26 及以下       | 1.0.x                    | | ||||
| | 0.27 - 0.28       | 2.x                      | | ||||
| | 0.29 - 0.33       | 3.x                      | | ||||
| | 0.34 - 0.45       | 4.x                      | | ||||
| | 0.46 及以上       | 5.x                      | | ||||
| | 0.34 - 0.45       | 4.x                      | | ||||
| | 0.46 及以上       | 5.x                      | | ||||
|  | ||||
| ### 优势 | ||||
|  | ||||
| @@ -58,6 +58,6 @@ | ||||
|  | ||||
| ### 关于我们 | ||||
|  | ||||
| 本组件由[React Native 中文网](http://reactnative.cn/)独家发布,如有定制需求可以[联系我们](http://reactnative.cn/about.html#content)。 | ||||
| 本组件由[React Native 中文网](https://reactnative.cn/)独家发布,如有定制需求可以[联系我们](https://reactnative.cn/about.html#content)。 | ||||
|  | ||||
| 关于此插件发现任何问题,可以前往[Issues](https://github.com/reactnativecn/react-native-pushy/issues)或者[中文社区](http://bbs.reactnative.cn/category/7)发帖提问。 | ||||
|   | ||||
| @@ -59,7 +59,7 @@ | ||||
|  | ||||
| 已经移除的应用、包版本、热更新版本不在统计之列,所以你可以移除测试时产生的和已过期版本来更有效的利用空间。 | ||||
|  | ||||
| 我们会在将来推出付费的升级版本,针对用户量较大、版本迭代较快的用户提供扩容方案。如果您有急迫的需求,可以[联系我们](http://reactnative.cn/about.html#content)。 | ||||
| 我们会在将来推出付费的升级版本,针对用户量较大、版本迭代较快的用户提供扩容方案。如果您有急迫的需求,可以[联系我们](https://reactnative.cn/about.html#content)。 | ||||
|  | ||||
| #### 我是否可以搭建自己的热更新服务? | ||||
|  | ||||
| @@ -67,5 +67,5 @@ | ||||
|  | ||||
| 这些功能都不会使用我们的热更新服务,也无需注册或登录账号。但你可能要编写自己的js模块来与不同的热更新服务器通讯。 | ||||
|  | ||||
| 如果您有兴趣使用我们的成果,搭建私有云服务,可以[联系我们](http://reactnative.cn/about.html#content)。 | ||||
| 如果您有兴趣使用我们的成果,搭建私有云服务,可以[联系我们](https://reactnative.cn/about.html#content)。 | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| 首先你应该有一个基于React Native开发的应用,我们把具有package.json的目录叫做你的"应用根目录"。 | ||||
|  | ||||
| 如果你还没有初始化应用,请参阅[开始使用React Native](http://reactnative.cn/docs/getting-started.html#content)。 | ||||
| 如果你还没有初始化应用,请参阅[开始使用React Native](https://reactnative.cn/docs/getting-started.html#content)。 | ||||
|  | ||||
| 所以我们也假设你已经拥有了开发React Native应用的一切环境,包括`Node.js`、`npm`、`XCode`、`Android SDK`等等。 | ||||
|  | ||||
| @@ -142,28 +142,9 @@ public class MainActivity extends ReactActivity { | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ## 三、iOS的ATS例外配置 | ||||
| 从iOS9开始,苹果要求以白名单的形式在Info.plist中列出外部的非https接口,以督促开发者部署https协议。在我们的服务部署https协议之前,请在Info.plist中添加如下例外(右键点击Info.plist,选择open as - source code): | ||||
| ```xml | ||||
| <key>NSAppTransportSecurity</key> | ||||
| <dict> | ||||
|     <key>NSExceptionDomains</key> | ||||
|     <dict> | ||||
|         <key>reactnative.cn</key> | ||||
|         <dict> | ||||
|             <key>NSIncludesSubdomains</key> | ||||
|             <true/> | ||||
|             <key>NSExceptionAllowsInsecureHTTPLoads</key> | ||||
|             <true/> | ||||
|         </dict> | ||||
|    </dict> | ||||
| </dict> | ||||
| ``` | ||||
| ## 三、登录与创建应用 | ||||
|  | ||||
|  | ||||
| ## 四、登录与创建应用 | ||||
|  | ||||
| 首先请在<http://update.reactnative.cn>注册帐号,然后在你的项目根目录下运行以下命令: | ||||
| 首先请在<https://update.reactnative.cn>注册帐号,然后在你的项目根目录下运行以下命令: | ||||
|  | ||||
| ```bash | ||||
| $ pushy login | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  | ||||
| ## 发布iOS应用 | ||||
|  | ||||
| 首先参考[文档-在设备上运行](http://reactnative.cn/docs/running-on-device-ios.html#content), | ||||
| 首先参考[文档-在设备上运行](https://reactnative.cn/docs/running-on-device-ios.html#content), | ||||
| 确定你正在使用离线包。然后点击菜单。 | ||||
|  | ||||
| 按照正常的发布流程打包`.ipa`文件(Xcode中运行设备选真机或Generic iOS Device,然后菜单中选择Product-Archive),然后运行如下命令 | ||||
| @@ -22,7 +22,7 @@ $ pushy uploadIpa <your-package.ipa> | ||||
|  | ||||
| ## 发布安卓应用 | ||||
|  | ||||
| 首先参考[文档-生成已签名的APK](http://reactnative.cn/docs/signed-apk-android.html#content)设置签名, | ||||
| 首先参考[文档-生成已签名的APK](https://reactnative.cn/docs/signed-apk-android.html#content)设置签名, | ||||
| 然后在android文件夹下运行`./gradlew assembleRelease`,你就可以在`android/app/build/outputs/apk/app-release.apk`中找到你的应用包。 | ||||
|  | ||||
| 然后运行如下命令 | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
| const HotUpdate = require('react-native').NativeModules.HotUpdate; | ||||
| import {NativeAppEventEmitter} from 'react-native'; | ||||
|  | ||||
| let host = 'http://update.reactnative.cn/api'; | ||||
| let host = 'https://update.reactnative.cn/api'; | ||||
|  | ||||
| export const downloadRootDir = HotUpdate.downloadRootDir; | ||||
| export const packageVersion = HotUpdate.packageVersion; | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|  */ | ||||
|  | ||||
| const fetch = require('isomorphic-fetch'); | ||||
| let host = process.env.PUSHY_REGISTRY || 'http://update.reactnative.cn/api'; | ||||
| let host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api'; | ||||
| const fs = require('fs-promise'); | ||||
| import * as fsOrigin from 'fs'; | ||||
| import request from 'request'; | ||||
| @@ -22,17 +22,17 @@ exports.loadSession = async function() { | ||||
|       throw e; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| }; | ||||
|  | ||||
| exports.getSession = function(){ | ||||
| exports.getSession = function() { | ||||
|   return session; | ||||
| } | ||||
| }; | ||||
|  | ||||
| exports.replaceSession = function(newSession) { | ||||
|   session = newSession; | ||||
| } | ||||
| }; | ||||
|  | ||||
| exports.saveSession = async function(){ | ||||
| exports.saveSession = async function() { | ||||
|   // Only save on change. | ||||
|   if (session !== savedSession) { | ||||
|     const current = session; | ||||
| @@ -40,22 +40,22 @@ exports.saveSession = async function(){ | ||||
|     await fs.writeFile('.update', data, 'utf8'); | ||||
|     savedSession = current; | ||||
|   } | ||||
| } | ||||
| }; | ||||
|  | ||||
| exports.closeSession = async function(){ | ||||
| exports.closeSession = async function() { | ||||
|   if (await fs.exists('.update')) { | ||||
|     await fs.unlink('.update'); | ||||
|     savedSession = undefined; | ||||
|   } | ||||
|   session = undefined; | ||||
|   host = process.env.PUSHY_REGISTRY || 'http://update.reactnative.cn'; | ||||
| } | ||||
|   host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn'; | ||||
| }; | ||||
|  | ||||
| async function query(url, options) { | ||||
|   const resp = await fetch(url, options); | ||||
|   const json = await resp.json(); | ||||
|   if (resp.status !== 200) { | ||||
|     throw Object.assign(new Error(json.message || json.error), {status: resp.status}); | ||||
|     throw Object.assign(new Error(json.message || json.error), { status: resp.status }); | ||||
|   } | ||||
|   return json; | ||||
| } | ||||
| @@ -90,7 +90,7 @@ exports.put = queryWithBody('PUT'); | ||||
| exports.doDelete = queryWithBody('DELETE'); | ||||
|  | ||||
| async function uploadFile(fn) { | ||||
|   const {url, fieldName, formData} = await exports.post('/upload', {}); | ||||
|   const { url, fieldName, formData } = await exports.post('/upload', {}); | ||||
|   let realUrl = url; | ||||
|  | ||||
|   if (!/^https?\:\/\//.test(url)) { | ||||
| @@ -110,18 +110,22 @@ async function uploadFile(fn) { | ||||
|  | ||||
|     formData.file.on('data', function(data) { | ||||
|       bar.tick(data.length); | ||||
|     }) | ||||
|     request.post(realUrl, { | ||||
|       formData, | ||||
|     }, (err, resp, body) => { | ||||
|       if (err) { | ||||
|         return reject(err); | ||||
|       } | ||||
|       if (resp.statusCode > 299) { | ||||
|         return reject(Object.assign(new Error(body), {status: resp.statusCode})); | ||||
|       } | ||||
|       resolve(JSON.parse(body)); | ||||
|     }) | ||||
|     }); | ||||
|     request.post( | ||||
|       realUrl, | ||||
|       { | ||||
|         formData, | ||||
|       }, | ||||
|       (err, resp, body) => { | ||||
|         if (err) { | ||||
|           return reject(err); | ||||
|         } | ||||
|         if (resp.statusCode > 299) { | ||||
|           return reject(Object.assign(new Error(body), { status: resp.statusCode })); | ||||
|         } | ||||
|         resolve(JSON.parse(body)); | ||||
|       }, | ||||
|     ); | ||||
|   }); | ||||
|   return info; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm