How to use react-native-code-push - 10 common examples

To help you get started, we’ve selected a few react-native-code-push examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duheng / Mozi / src / root.js View on Github external
* Author: 墨子
 * GitHub: https://github.com/duheng/Mozi
 * Email: duheng1100@163.com
 */
import React, { Component, } from 'react';
import { Provider, } from 'react-redux';
import SplashScreen from 'react-native-splash-screen';
import codePush from 'react-native-code-push';
import configureStore from './app/store/configureStore';
import App from './AppNavigationState';

const store = configureStore();

@codePush({
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_SUSPEND,
})
export default class Root extends Component {
  componentDidMount() {
    SplashScreen.hide(); // 隐藏启动屏
  }

  render() {
    console.log('store----', store);
    return (
      
        
      
    );
  }
}
github duheng / Mozi / src / root.js View on Github external
/**
 * Author: 墨子
 * GitHub: https://github.com/duheng/Mozi
 * Email: duheng1100@163.com
 */
import React, { Component, } from 'react';
import { Provider, } from 'react-redux';
import SplashScreen from 'react-native-splash-screen';
import codePush from 'react-native-code-push';
import configureStore from './app/store/configureStore';
import App from './AppNavigationState';

const store = configureStore();

@codePush({
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_SUSPEND,
})
export default class Root extends Component {
  componentDidMount() {
    SplashScreen.hide(); // 隐藏启动屏
  }

  render() {
    console.log('store----', store);
    return (
      
        
      
    );
  }
github duheng / Mozi / src / root.js View on Github external
/**
 * Author: 墨子
 * GitHub: https://github.com/duheng/Mozi
 * Email: duheng1100@163.com
 */
import React, { Component, } from 'react';
import { Provider, } from 'react-redux';
import SplashScreen from 'react-native-splash-screen';
import codePush from 'react-native-code-push';
import configureStore from './app/store/configureStore';
import App from './AppNavigationState';

const store = configureStore();

@codePush({
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_SUSPEND,
})
export default class Root extends Component {
  componentDidMount() {
    SplashScreen.hide(); // 隐藏启动屏
  }

  render() {
    console.log('store----', store);
    return (
      
        
      
    );
  }
}
github sishuguojixuefu / react-native-template-sishu-0.59 / app / utils / CodePushSync.ts View on Github external
const codePushStatusDidChange = (syncStatus: number) => {
  switch (syncStatus) {
    case CodePush.SyncStatus.UP_TO_DATE: // 已更新 0
      console.info(`[CodePush]${syncStatus}: 已更新`)
      break
    case CodePush.SyncStatus.INSTALLING_UPDATE: // 下载更新 1
      console.info(`[CodePush]${syncStatus}: 下载更新`)
      break
    case CodePush.SyncStatus.UPDATE_IGNORED: // 忽略更新 2
      console.info(`[CodePush]${syncStatus}: 忽略更新`)
      break
    case CodePush.SyncStatus.UNKNOWN_ERROR: // 未知错误 3
      console.info(`[CodePush]${syncStatus}: 未知错误`)
      break
    case CodePush.SyncStatus.SYNC_IN_PROGRESS: // 正在同步 4
      console.info(`[CodePush]${syncStatus}: 正在同步`)
      break
    case CodePush.SyncStatus.CHECKING_FOR_UPDATE: // 检查更新 5
      console.info(`[CodePush]${syncStatus}: 检查更新`)
      break
    case CodePush.SyncStatus.AWAITING_USER_ACTION: // 等待用户操作 6
      console.info(`[CodePush]${syncStatus}: 等待用户操作`)
      break
    case CodePush.SyncStatus.DOWNLOADING_PACKAGE: // 正在下载 7
      console.info(`[CodePush]${syncStatus}: 正在下载`)
github sishuguojixuefu / react-native-template-sishu-0.59 / app / utils / CodePushSync.ts View on Github external
CodePush.sync({ installMode: CodePush.InstallMode.IMMEDIATE }, codePushStatusDidChange, progress => {
    console.info('[CodePush]codePushDownloadDidProgress: ', progress)
    if (progress.receivedBytes >= progress.totalBytes) {
      console.info('[CodePush]syncImmediate-强制更新')
      CodePush.allowRestart() // 强制更新
    }
  })
}
github sishuguojixuefu / react-native-template-sishu-0.59 / app / utils / CodePushSync.ts View on Github external
const syncImmediate = () => {
  console.info('[CodePush]syncImmediate: 安装更新并立刻重启应用')
  CodePush.disallowRestart() // 禁止重启
  CodePush.sync({ installMode: CodePush.InstallMode.IMMEDIATE }, codePushStatusDidChange, progress => {
    console.info('[CodePush]codePushDownloadDidProgress: ', progress)
    if (progress.receivedBytes >= progress.totalBytes) {
      console.info('[CodePush]syncImmediate-强制更新')
      CodePush.allowRestart() // 强制更新
    }
  })
}
github birkir / hekla / src / screens / settings / About.tsx View on Github external
onBetaChange(flag: boolean) {
    // TODO: Prompt user to confirm and that the app will likely restart.
    UI.settings.setValue('isBeta', flag);
    const config = codePushConfig();
    config.installMode = CodePush.InstallMode.IMMEDIATE;
    CodePush.sync(config);
  }
github FuYaoDe / 30-days-of-react-native / src / containers / Router.js View on Github external
componentDidMount() {

    CodePush.checkForUpdate()
    .then( (update) =>{
        if( !update ){
            Alert.alert("app是最新版了");
        }else {
            Alert.alert("有更新哦");
        }
    });

    CodePush.sync({ updateDialog: true, installMode: CodePush.InstallMode.IMMEDIATE },
      (status) => {
        switch (status) {
          case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
            // this.setState({showDownloadingModal: true});
            // this.refs.modal.open();
            break;
          case CodePush.SyncStatus.INSTALLING_UPDATE:
            // this.setState({showInstalling: true});
            break;
          case CodePush.SyncStatus.UPDATE_INSTALLED:
            // this.refs.modal.close();
            // this.setState({showDownloadingModal: false});
            break;
        }
      },
      ({ receivedBytes, totalBytes, }) => {
github NSWSESMembers / availability-poc / client / index.js View on Github external
import {
  AppRegistry,
  YellowBox,
} from 'react-native';
import codePush from 'react-native-code-push';
import App from './src/app';

const codePushOptions = {
  checkFrequency: (
    (!__DEV__) ? codePush.CheckFrequency.ON_APP_RESUME
      : codePush.CheckFrequency.MANUAL),
  updateDialog: true,
  installMode: codePush.InstallMode.IMMEDIATE,
};

// suppress false-positive isMounted() deprecation warning
// proper fix coming from react-native soon:
// https://github.com/facebook/react-native/issues/18868#issuecomment-387627007
if (YellowBox) {
  YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
}

AppRegistry.registerComponent(
  'Callout',
  () => codePush(codePushOptions)(App),
);
github FuYaoDe / 30-days-of-react-native / src / containers / Router.js View on Github external
(status) => {
        switch (status) {
          case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
            // this.setState({showDownloadingModal: true});
            // this.refs.modal.open();
            break;
          case CodePush.SyncStatus.INSTALLING_UPDATE:
            // this.setState({showInstalling: true});
            break;
          case CodePush.SyncStatus.UPDATE_INSTALLED:
            // this.refs.modal.close();
            // this.setState({showDownloadingModal: false});
            break;
        }
      },
      ({ receivedBytes, totalBytes, }) => {