@startupjs/codepush
Dynamically push JS-only updates to the React Native apps
Last updated a day ago by yska .
Original npm · Tarball · package.json
$ cnpm install @startupjs/codepush 
SYNC missed versions from official npm registry.

startupjs codepush

Dynamically push JS-only updates to the React Native apps

Installation

yarn add @startupjs/codepush

Setup

CodePush is a cloud service that enables React Native developers to deploy mobile app updates instantly to all the devices of users.

Do the following steps to configure it for your project:

  1. Install CodePush CLI
npm install -g code-push-cli
  1. Create/Login a CodePush account
// Register
code-push register

// Login if registered already
code-push login
  1. Register your app
// For Android
code-push app add <App-Name-Android> android react-native

// For iOS
code-push app add <App-Name-Ios> ios react-native

Android

  1. Add empty reactNativeCodePush_androidDeploymentKey string item to /path_to_your_app/android/app/src/main/res/values/strings.xml. It should look similar to the following:
<resources>
  <string name="reactNativeCodePush_androidDeploymentKey" moduleConfig="true"></string>
  <string name="app_name">MyCoolApp</string>
</resources>
  1. Get keys using code-push deployment ls <App-Name-Android> --displayKeys and copy both Debug and Release key in /path_to_your_app/android/app/build.gradle

codepush android

  1. Go to /path_to_your_app/android/app/src/main/java/com/lingua/MainApplication.java and add code which set keys. It should look similar to this:
@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  // Set CodePush deployment keys here, because
  // we can't set different keys for debug and
  // release on strings.xml (reactNativeCodePush_androidDeploymentKey)
  for(ReactPackage reactPackage: packages) {
    if (reactPackage instanceof CodePush) {
      ((CodePush)reactPackage).setDeploymentKey(BuildConfig.CODEPUSH_KEY);
    }
  }
  return packages;
}

iOS

  1. Add CodePushDeploymentKey string item with value $(CODEPUSH_KEY) to /path_to_your_app/ios/your_app/Info.plist. It may looks like this:
<plist version="1.0">
<dict>
<!-- ...other configs... -->
<key>CFBundleVersion</key>
<string>1</string>
<key>CodePushDeploymentKey</key>
<string>$(CODEPUSH_KEY)</string>
<key>LSRequiresIPhoneOS</key>
<!-- ...other configs... -->
</dict>
</plist>
  1. Get keys using code-push deployment ls <App-Name-Ios> --displayKeys then open /path_to_your_app/ios using Xcode and copy both Debug and Release key in

codepush ios

Usage

import App from './App'
import codepush from '@startupjs/codepush'
export default codepush(App)

How to publish new version with CodePush

By default the releases are non-critical. Which means that the update will be pushed to the application whenever the user opens it or goes back into it from the sleep mode.

In case your change is critical and requires force update, you can specify the --mandatory or -m flag. This way the application will be blocked by a popup even if the user is currently actively using the app. And the only way for user to continue will be to accept the popup dialog asking to update and restart the app.

appcenter codepush release-react -a ownerName/appName -d Production --description "Some description" --mandatory (optional)

IMPORTANT (iOS): By default codepush using default plist file located at ios/%PROJECT%/Info.plist. If your file have another location or name you can specify plist file in command above by adding --plist-file path/to/Info.plist.

References

Current Tags

  • 0.23.45                                ...           latest (a day ago)
  • 0.22.0-alpha.24                                ...           next (4 months ago)

29 Versions

  • 0.23.45                                ...           a day ago
  • 0.23.44                                ...           a day ago
  • 0.23.0                                ...           3 months ago
  • 0.22.0                                ...           3 months ago
  • 0.22.0-alpha.24                                ...           4 months ago
  • 0.22.0-alpha.23                                ...           4 months ago
  • 0.22.0-alpha.22                                ...           4 months ago
  • 0.22.0-alpha.20                                ...           4 months ago
  • 0.22.0-alpha.0                                ...           5 months ago
  • 0.21.1                                ...           5 months ago
  • 0.21.0                                ...           5 months ago
  • 0.20.0                                ...           5 months ago
  • 0.19.2                                ...           5 months ago
  • 0.19.1                                ...           5 months ago
  • 0.19.0                                ...           6 months ago
  • 0.18.4                                ...           6 months ago
  • 0.18.3                                ...           6 months ago
  • 0.18.2                                ...           6 months ago
  • 0.18.1                                ...           6 months ago
  • 0.18.0                                ...           6 months ago
  • 0.17.3                                ...           6 months ago
  • 0.17.2                                ...           6 months ago
  • 0.17.0                                ...           6 months ago
  • 0.16.2                                ...           6 months ago
  • 0.16.0                                ...           6 months ago
  • 0.15.5                                ...           7 months ago
  • 0.15.0                                ...           7 months ago
  • 0.14.1                                ...           8 months ago
  • 0.13.0                                ...           8 months ago
Downloads
Today 0
This Week 49
This Month 0
Last Day 49
Last Week 0
Last Month 49
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |