反応し、ネイティブのホットアップデート - 3分で教えるためにあなたが実現

ハハ、今日は最初の記事、質問に来ると書かれた簡潔に大きな豚で、最新バージョンの使用して、この記事のパラメータはあまり詳細に説明されていないプレゼンテーションは、より多くのパラメータは、他の記事を参照して説明することができ、ここでのAPPは今だけ一緒に幸せな大豚に続いて、便利なクイックスタートを通常のホット更新操作を保証することができます。RNCode-Push

9028759-597468bb2d19c516.png

操作ガイド

大きな豚はついにマックを購入する余裕が後に次の操作が長年にわたり、すべての後に、Macのシステム上で完了します。

  1. 作成React-Nativeプロジェクト
react-native init dounineApp
  1. インストールcode-push-cli
npm install -g code-push-cli
  1. 登録code-pushアカウント
code-push register
Please login to Mobile Center in the browser window we've just opened.

Enter your token from the browser: 
#会弹出一个浏览器,让你注册,可以使用github帐号对其进行授权,授权成功会给一串Token,点击复制,在控制进行粘贴回车(或者使用code-push login命令)。
Enter your token from the browser:  b0c9ba1f91dd232xxxxxxxxxxxxxxxxx
#成功提示如下方
Successfully logged-in. Your session file was written to /Users/huanghuanlai/.code-push.config. You can run the code-push logout command at any time to delete this file and terminate your session.
9028759-7736182c03cea82a.png
  1. ではcode-pushアプリのIOSを追加します
code-push app add dounineApp-ios ios react-native
#成功提示如下方
Successfully added the "dounineApp-ios" app, along with the following default deployments:
┌────────────┬──────────────────────────────────────────────────────────────────┐
│ Name       │ Deployment Key                                                   │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Production │ yMAPMAjXpfXoTfxCd0Su9c4-U4lU6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Staging    │ IjC3_iRGEZE8-9ikmBZ4ITJTz9wn6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │
└────────────┴──────────────────────────────────────────────────────────────────┘
  1. 続けてcode-pushAndroidアプリを追加すること
code-push app add dounineApp-android android react-native
#成功提示如下方
Successfully added the "dounineApp-android" app, along with the following default deployments:
┌────────────┬──────────────────────────────────────────────────────────────────┐
│ Name       │ Deployment Key                                                   │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Production │ PZVCGLlVW-0FtdoCF-3ZDWLcX58L6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │
├────────────┼──────────────────────────────────────────────────────────────────┤
│ Staging    │ T0NshYi9X8nRkIe_cIRZGbAut90a6dec4087-57cf-4c9d-b0dc-ad38ce431e1d │
└────────────┴──────────────────────────────────────────────────────────────────┘
  1. プロジェクトのルートディレクトリに追加します。react-native-code-push
npm install react-native-code-push --save
#或者
yarn add react-native-code-push
  1. リンク反応するネイティブ・コード・プッシュ
react-native link
Scanning folders for symlinks in /Users/huanghuanlai/dounine/oschina/dounineApp/node_modules (8ms)
? What is your CodePush deployment key for Android (hit <ENTER> to ignore) T0NshYi9X8nRkIe_cIRZGbAut90a6dec4087-57cf-4c9d-b0dc-ad38ce431e1d

#将刚才添加的Android App的Deployment Key复制粘贴到这里,复制名为Staging测试Deployment Key。

rnpm-install info Linking react-native-code-push android dependency 
rnpm-install info Android module react-native-code-push has been successfully linked 
rnpm-install info Linking react-native-code-push ios dependency 
rnpm-install WARN ERRGROUP Group 'Frameworks' does not exist in your Xcode project. We have created it automatically for you.
rnpm-install info iOS module react-native-code-push has been successfully linked 
Running ios postlink script
? What is your CodePush deployment key for iOS (hit <ENTER> to ignore) IjC3_iRGEZE8-9ikmBZ4ITJTz9wn6dec4087-57cf-4c9d-b0dc-ad38ce431e1d

#继续复制Ios的Deployment Key

Running android postlink script
  1. ファイルの追加コードを自動的に更新しますreact-nativeApp.js
import codePush from "react-native-code-push";
const codePushOptions = { checkFrequency: codePush.CheckFrequency.MANUAL };
export default class App extends Component<{}> {
  
  componentDidMount(){
    codePush.sync({
      updateDialog: true,
      installMode: codePush.InstallMode.IMMEDIATE,
      mandatoryInstallMode:codePush.InstallMode.IMMEDIATE,
      //deploymentKey为刚才生成的,打包哪个平台的App就使用哪个Key,这里用IOS的打包测试
      deploymentKey: 'IjC3_iRGEZE8-9ikmBZ4ITJTz9wn6dec4087-57cf-4c9d-b0dc-ad38ce431e1d',
      });
  }
  ...
  1. iOSシミュレータ上でプロジェクトを実行します
react-native run-ios

次の重要な図。

1:デバッグを開きます

2:CodePush既にされています

アプリは現在、最新バージョンを持っています

9028759-41607a87f412b06a.png
  1. IOSの新バージョンをリリース
code-push release-react dounineApp-ios ios

下に示す掲示される成功

Detecting ios app version:

Using the target binary version value "1.0" from "ios/dounineApp/Info.plist".

Running "react-native bundle" command:

node node_modules/react-native/local-cli/cli.js bundle --assets-dest /var/folders/m_/xcdff0xd62j4l2xbn_nfz00w0000gn/T/CodePush --bundle-output /var/folders/m_/xcdff0xd62j4l2xbn_nfz00w0000gn/T/CodePush/main.jsbundle --dev false --entry-file index.js --platform ios
Scanning folders for symlinks in /Users/huanghuanlai/dounine/oschina/dounineApp/node_modules (10ms)
Scanning folders for symlinks in /Users/huanghuanlai/dounine/oschina/dounineApp/node_modules (10ms)
Loading dependency graph, done.

bundle: start
bundle: finish
bundle: Writing bundle output to: /var/folders/m_/xcdff0xd62j4l2xbn_nfz00w0000gn/T/CodePush/main.jsbundle
bundle: Done writing bundle output

Releasing update contents to CodePush:

Upload progress:[==================================================] 100% 0.0s
Successfully released an update containing the "/var/folders/m_/xcdff0xd62j4l2xbn_nfz00w0000gn/T/CodePush" directory to the "Staging" deployment of the "dounineApp-ios" app.
  1. 再負荷アプリケーションを更新
9028759-30c17d2f5db173cd.png
  1. アンドリュースリリース

9〜11と上記のステップは、単純化されたコマンドの結果、アンドロイドに対応するコマンド、同じです

アンドロイドへdeploymentKeyの1.修正App.js

deploymentKey:'T0NshYi9X8nRkIe_cIRZGbAut90a6dec4087-57cf-4c9d-b0dc-ad38ce431e1d'

2.ファイル名を指定して実行

react-native run-android

3.公開

code-push release-react dounineApp-android android

前記リフレッシュ・アプリケーション、以下に示すように

9028759-172d8b5d3b650bbb.png

福祉プロジェクトのソース


9028759-5619fe0d9edd7a1b.png

おすすめ

転載: blog.csdn.net/weixin_34367845/article/details/90840095