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://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 版本 | | | React Native 版本 | react-native-update 版本 | | ||||||
| | ----------------- | ------------------------ | | | ----------------- | ------------------------ | | ||||||
| | 0.26 及以下       | 1.0.x                    | | | 0.26 及以下       | 1.0.x                    | | ||||||
| | 0.27 - 0.28       | 2.x                      | | | 0.27 - 0.28       | 2.x                      | | ||||||
| | 0.29 - 0.33       | 3.x                      | | | 0.29 - 0.33       | 3.x                      | | ||||||
| | 0.34 - 0.45       | 4.x                      | | | 0.34 - 0.45       | 4.x                      | | ||||||
| | 0.46 及以上       | 5.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)发帖提问。 | 关于此插件发现任何问题,可以前往[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模块来与不同的热更新服务器通讯。 | 这些功能都不会使用我们的热更新服务,也无需注册或登录账号。但你可能要编写自己的js模块来与不同的热更新服务器通讯。 | ||||||
|  |  | ||||||
| 如果您有兴趣使用我们的成果,搭建私有云服务,可以[联系我们](http://reactnative.cn/about.html#content)。 | 如果您有兴趣使用我们的成果,搭建私有云服务,可以[联系我们](https://reactnative.cn/about.html#content)。 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| 首先你应该有一个基于React Native开发的应用,我们把具有package.json的目录叫做你的"应用根目录"。 | 首先你应该有一个基于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`等等。 | 所以我们也假设你已经拥有了开发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> |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|  | 首先请在<https://update.reactnative.cn>注册帐号,然后在你的项目根目录下运行以下命令: | ||||||
| ## 四、登录与创建应用 |  | ||||||
|  |  | ||||||
| 首先请在<http://update.reactnative.cn>注册帐号,然后在你的项目根目录下运行以下命令: |  | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| $ pushy login | $ pushy login | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  |  | ||||||
| ## 发布iOS应用 | ## 发布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),然后运行如下命令 | 按照正常的发布流程打包`.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`中找到你的应用包。 | 然后在android文件夹下运行`./gradlew assembleRelease`,你就可以在`android/app/build/outputs/apk/app-release.apk`中找到你的应用包。 | ||||||
|  |  | ||||||
| 然后运行如下命令 | 然后运行如下命令 | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| const HotUpdate = require('react-native').NativeModules.HotUpdate; | const HotUpdate = require('react-native').NativeModules.HotUpdate; | ||||||
| import {NativeAppEventEmitter} from 'react-native'; | 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 downloadRootDir = HotUpdate.downloadRootDir; | ||||||
| export const packageVersion = HotUpdate.packageVersion; | export const packageVersion = HotUpdate.packageVersion; | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| const fetch = require('isomorphic-fetch'); | 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'); | const fs = require('fs-promise'); | ||||||
| import * as fsOrigin from 'fs'; | import * as fsOrigin from 'fs'; | ||||||
| import request from 'request'; | import request from 'request'; | ||||||
| @@ -22,17 +22,17 @@ exports.loadSession = async function() { | |||||||
|       throw e; |       throw e; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | }; | ||||||
|  |  | ||||||
| exports.getSession = function(){ | exports.getSession = function() { | ||||||
|   return session; |   return session; | ||||||
| } | }; | ||||||
|  |  | ||||||
| exports.replaceSession = function(newSession) { | exports.replaceSession = function(newSession) { | ||||||
|   session = newSession; |   session = newSession; | ||||||
| } | }; | ||||||
|  |  | ||||||
| exports.saveSession = async function(){ | exports.saveSession = async function() { | ||||||
|   // Only save on change. |   // Only save on change. | ||||||
|   if (session !== savedSession) { |   if (session !== savedSession) { | ||||||
|     const current = session; |     const current = session; | ||||||
| @@ -40,22 +40,22 @@ exports.saveSession = async function(){ | |||||||
|     await fs.writeFile('.update', data, 'utf8'); |     await fs.writeFile('.update', data, 'utf8'); | ||||||
|     savedSession = current; |     savedSession = current; | ||||||
|   } |   } | ||||||
| } | }; | ||||||
|  |  | ||||||
| exports.closeSession = async function(){ | exports.closeSession = async function() { | ||||||
|   if (await fs.exists('.update')) { |   if (await fs.exists('.update')) { | ||||||
|     await fs.unlink('.update'); |     await fs.unlink('.update'); | ||||||
|     savedSession = undefined; |     savedSession = undefined; | ||||||
|   } |   } | ||||||
|   session = 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) { | async function query(url, options) { | ||||||
|   const resp = await fetch(url, options); |   const resp = await fetch(url, options); | ||||||
|   const json = await resp.json(); |   const json = await resp.json(); | ||||||
|   if (resp.status !== 200) { |   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; |   return json; | ||||||
| } | } | ||||||
| @@ -90,7 +90,7 @@ exports.put = queryWithBody('PUT'); | |||||||
| exports.doDelete = queryWithBody('DELETE'); | exports.doDelete = queryWithBody('DELETE'); | ||||||
|  |  | ||||||
| async function uploadFile(fn) { | async function uploadFile(fn) { | ||||||
|   const {url, fieldName, formData} = await exports.post('/upload', {}); |   const { url, fieldName, formData } = await exports.post('/upload', {}); | ||||||
|   let realUrl = url; |   let realUrl = url; | ||||||
|  |  | ||||||
|   if (!/^https?\:\/\//.test(url)) { |   if (!/^https?\:\/\//.test(url)) { | ||||||
| @@ -110,20 +110,24 @@ async function uploadFile(fn) { | |||||||
|  |  | ||||||
|     formData.file.on('data', function(data) { |     formData.file.on('data', function(data) { | ||||||
|       bar.tick(data.length); |       bar.tick(data.length); | ||||||
|     }) |     }); | ||||||
|     request.post(realUrl, { |     request.post( | ||||||
|       formData, |       realUrl, | ||||||
|     }, (err, resp, body) => { |       { | ||||||
|       if (err) { |         formData, | ||||||
|         return reject(err); |       }, | ||||||
|       } |       (err, resp, body) => { | ||||||
|       if (resp.statusCode > 299) { |         if (err) { | ||||||
|         return reject(Object.assign(new Error(body), {status: resp.statusCode})); |           return reject(err); | ||||||
|       } |         } | ||||||
|       resolve(JSON.parse(body)); |         if (resp.statusCode > 299) { | ||||||
|     }) |           return reject(Object.assign(new Error(body), { status: resp.statusCode })); | ||||||
|  |         } | ||||||
|  |         resolve(JSON.parse(body)); | ||||||
|  |       }, | ||||||
|  |     ); | ||||||
|   }); |   }); | ||||||
|   return info; |   return info; | ||||||
| } | } | ||||||
|  |  | ||||||
| exports.uploadFile = uploadFile; | exports.uploadFile = uploadFile; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm