Exemplo n.º 1
0
 AppState.addEventListener('change', (newState) => {
   if (newState === 'active') {
     codePush.sync({
       installMode: InstallMode.IMMEDIATE,
     }); // {installMode: InstallMode.ON_NEXT_RESTART}
   }
 });
Exemplo n.º 2
0
export function callCodePush(){

    //隐式更新
    codePush.sync(); 

    /*
    let updateDialogOptions = {
        title: "更新提示",
        optionalUpdateMessage: "检测到可用的新版本,是否升级?",
        optionalIgnoreButtonLabel: "无视",
        optionalInstallButtonLabel: "升级",
    };
    //显式更新
	codePush.sync(
        { 
            updateDialog: updateDialogOptions
        }, 
        (status)=>{
            if (status == codePush.SyncStatus.INSTALLING_UPDATE) {
               
            }
        }
    );
    */
}
Exemplo n.º 3
0
 /** Update pops a confirmation dialog, and then immediately reboots the app */
 syncImmediate() {
   CodePush.sync(
     { installMode: CodePush.InstallMode.IMMEDIATE, updateDialog: true },
     this.codePushStatusDidChange.bind(this),
     this.codePushDownloadDidProgress.bind(this)
   );
 }
Exemplo n.º 4
0
export default function updateCheck() {
  codePush.sync({
    deploymentKey: '43ENH2WbHU9EgYYtD7ofoMR7qRwNE1M-WAV0l',
    updateDialog: true,
    installMode: codePush.InstallMode.IMMEDIATE
  });
}
Exemplo n.º 5
0
 updateDemo() {
   const onSyncStatusChange = (syncStatus) => {
     if (syncStatus !== 5) {
       this.setState({
         animating: false,
       });
     }
     switch (syncStatus) {
       case 0: Alert.alert(null, '最新版本'); break;
       case 3: Alert.alert(null, '发生错误'); break;
       default: break;
     }
   };
   const onError = function (error) {
     this.setState({
       animating: false,
     });
     Alert.alert(null, `发生错误: ${error}`);
   };
   codePush.sync({
     updateDialog: {
       updateTitle: '检测有更新',
       optionalUpdateMessage: 'demo app 有新版本,是否安装?',
       optionalIgnoreButtonLabel: 'No',
       optionalInstallButtonLabel: 'Yes',
     },
     installMode: codePush.InstallMode.IMMEDIATE,
   }, onSyncStatusChange, null, onError);
 }
Exemplo n.º 6
0
 /** Update is downloaded silently, and applied on restart (recommended) */
 sync() {
   CodePush.sync(
     {},
     this.codePushStatusDidChange.bind(this),
     this.codePushDownloadDidProgress.bind(this)
   );
 }
Exemplo n.º 7
0
 async _updateFromCodePush(){
     const self = this
     try{
         return await CodePush.sync({
             installMode: CodePush.InstallMode.IMMEDIATE,
         },syncStatus=>{
             switch(syncStatus) {
                 case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
                 self.setState({
                     syncMessage: "检查更新中..."
                 });
                 break;
                 case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
                 self.setState({
                     syncMessage: "更新包下载中..."
                 });
                 break;
                 case CodePush.SyncStatus.AWAITING_USER_ACTION:
                 self.setState({
                     syncMessage: "等待中..."
                 });
                 break;
                 case CodePush.SyncStatus.INSTALLING_UPDATE:
                 self.setState({
                     syncMessage: "安装更新包..."
                 });
                 break;
                 case CodePush.SyncStatus.UP_TO_DATE:
                 self.setState({
                     syncMessage: "已是最新版本",
                     progress: false
                 });
                 break;
                 case CodePush.SyncStatus.UPDATE_IGNORED:
                 self.setState({
                     syncMessage: "更新已暂停",
                     progress: false
                 });
                 break;
                 case CodePush.SyncStatus.UPDATE_INSTALLED:
                 self.setState({
                     syncMessage: "更新安装成功,下次重启更新生效",
                     progress: false
                 });
                 break;
                 case CodePush.SyncStatus.UNKNOWN_ERROR:
                 self.setState({
                     syncMessage: "未知的错误",
                     progress: false
                 });
                 break;
             }
         },progress=>{
             this.setState({progress})
         })
     }catch(e){
         CodePush.log(e)
         this._toast.show("更新服务器异常")
     }
 }
Exemplo n.º 8
0
 _handleAppStateChange(currentAppState) {
     if(currentAppState === 'active') {
         CodePush.sync({
             installMode: CodePush.InstallMode.ON_NEXT_RESUME
         });
     }
 }
Exemplo n.º 9
0
Arquivo: index.js Projeto: Almax/dev
 async componentDidMount() {
   if(Platform.OS === 'ios' && false) {
     let result = await codePush.checkForUpdate();
     if(result) {
       codePush.sync({ 
          updateDialog: {
           title: "发现婚格有更新",
           optionalUpdateMessage: "小主,app更新啦~快来更新",
           optionalInstallButtonLabel: "安装",
           optionalIgnoreButtonLabel: "下次再说",
           appendReleaseDescription: true,
           descriptionPrefix: "\n\n本次更新:\n"   
          },
         installMode: codePush.InstallMode.IMMEDIATE 
       }, (status) => {
         switch (status) {
           case codePush.SyncStatus.DOWNLOADING_PACKAGE:
               this.setState({ finished: false });
               break;
           case codePush.SyncStatus.INSTALLING_UPDATE:
               
               break;
           case codePush.SyncStatus.UPDATE_INSTALLED:
               Alert.alert("更新完成", "正在重启");
               break;
           case codePush.SyncStatus.SYNC_IN_PROGRESS: 
               
               break;
         }
       }, (progress) => {
         this.setState({ progress });
       });
     }
   }
 }
Exemplo n.º 10
0
  componentDidMount() {
      // this.setState({initialLoad: false}); // eslint-disable-line
    AsyncStorage.getItem(STORAGE_KEY).then((data) => {
      console.log(STORAGE_KEY);
      this.setState({initialLoad: false}); // eslint-disable-line
      if (data) {
        const {hostname, apiKey} = JSON.parse(data);
        apiActions.setHostname(hostname);
        apiActions.setApiKey(apiKey);
        this.setState({keyFound: true});
      }
    });

    codePush.sync({
      installMode: InstallMode.IMMEDIATE,
    });
    // Check for CodePush updates when app becomes active.
    AppState.addEventListener('change', (newState) => {
      if (newState === 'active') {
        codePush.sync({
          installMode: InstallMode.IMMEDIATE,
        }); // {installMode: InstallMode.ON_NEXT_RESTART}
      }
    });
  }
Exemplo n.º 11
0
Arquivo: Main.js Projeto: g0v/victim
 InteractionManager.runAfterInteractions(() => {
   CodePush.sync({}, (status) => {
     if (status === CodePush.SyncStatus.UPDATE_INSTALLED) {
       CodePush.restartApp();
     }
   });
 });
Exemplo n.º 12
0
 handleAppStateChange(appState) {
   if (appState === 'active') {
     CodePush.sync({
       installMode: CodePush.InstallMode.ON_NEXT_RESUME,
       minimumBackgroundDuration: 60 * 5,
     });
   }
 }
Exemplo n.º 13
0
 componentDidMount() {
   AppState.addEventListener('change', this.handleAppStateChange);
   CodePush.sync({
     installMode: CodePush.InstallMode.ON_NEXT_RESUME,
     minimumBackgroundDuration: 60 * 5,
   });
   Linking.addEventListener('url', this.handleOpenURL);
 }
Exemplo n.º 14
0
    componentDidMount() {
        // 首次启动时检查时候有更新
        CodePush.sync({
            installMode: CodePush.InstallMode.ON_NEXT_RESUME
        });

        AppState.addEventListener('change', this._handleAppStateChange.bind(this));
    }
Exemplo n.º 15
0
Arquivo: F8App.js Projeto: S4KH/f8app
 handleAppStateChange: function(appState) {
   if (appState === 'active') {
     this.props.dispatch(loadSessions());
     this.props.dispatch(loadNotifications());
     this.props.dispatch(loadSurveys());
     CodePush.sync({installMode: CodePush.InstallMode.ON_NEXT_RESUME});
   }
 },
Exemplo n.º 16
0
 AppState.addEventListener('change', currentAppState => {
    if (currentAppState === 'active') {
       codePush.sync({installMode: codePush.InstallMode.ON_NEXT_RESUME});
       this.refresh();
       this.startAutoUpdate();
    } else if (currentAppState === 'background' && this.updateInterval) {
       this.stopAutoUpdate();
    }
 });
Exemplo n.º 17
0
componentDidMount() {
CodePush.notifyApplicationReady();

      CodePush.sync({ deploymentKey: "VlOQwXQYJIeh667505A-PYkc4RoT4JVuG2y8W",
        updateDialog: true,
        //installMode: CodePush.InstallMode.ON_NEXT_RESUME
        installMode: CodePush.InstallMode.IMMEDIATE
      });
alert("I'm CodePush.notifyApplicationReady();");
  }
Exemplo n.º 18
0
 componentDidMount() {
   codePush.sync({
     updateDialog: {
       updateTitle: '检测有更新',
       optionalUpdateMessage: 'demo app 有新版本,是否安装?',
       optionalIgnoreButtonLabel: 'No',
       optionalInstallButtonLabel: 'Yes',
     },
   });
 }
 componentWillMount() {
     CodePush.sync({
         deploymentKey: 'm-riu3kK1__kGboK4WPIwBYs7ZwzEygDCEa5e',
         updateDialog: {
             optionalIgnoreButtonLabel: '稍后',
             optionalInstallButtonLabel: '后台更新',
             optionalUpdateMessage: '是否更新?---',
             title: '更新提示'
         },
         installMode: CodePush.InstallMode.IMMEDIATE
     });
 }
Exemplo n.º 20
0
 componentWillMount() {
   if (Platform.OS == 'ios') {
     codePush.sync();
   }
   this.popupListener = NativeAppEventEmitter.addListener('showPopup', (options) => {
     this.global_popup.tip({
       title: options.title,
       content: options.content,
       btn: { text: options.buttonText },
     });
   });
 }
Exemplo n.º 21
0
 componentDidMount() {
   CodePush.sync({
     deploymentKey: "RGOUfyINiLicZnld67aD0nrbRvyLV1Ifekvul",
     updateDialog: {
       optionalIgnoreButtonLabel: '稍后',
       optionalInstallButtonLabel: '后台更新',
       optionalUpdateMessage: 'Reading有新版本了,是否更新?',
       title: '更新提示'
     },
     installMode: CodePush.InstallMode.ON_NEXT_RESTART
   });
   AV.initialize('Tfi1z7dN9sjMwSul8sYaTEvg-gzGzoHsz', '57qmeEJonefntNqRe17dAgi4');
 }
Exemplo n.º 22
0
Arquivo: F8App.js Projeto: S4KH/f8app
  componentDidMount: function() {
    AppState.addEventListener('change', this.handleAppStateChange);

    // TODO: Make this list smaller, we basically download the whole internet
    this.props.dispatch(loadNotifications());
    this.props.dispatch(loadMaps());
    this.props.dispatch(loadConfig());
    this.props.dispatch(loadSessions());
    this.props.dispatch(loadFriendsSchedules());
    this.props.dispatch(loadSurveys());

    updateInstallation({version});
    CodePush.sync({installMode: CodePush.InstallMode.ON_NEXT_RESUME});
  },
Exemplo n.º 23
0
    componentDidMount () {

      //android注册返回事件
      BackAndroid.addEventListener('hardwareBackPress', ()=> {

          var iLength=this.refs.navigator.getCurrentRoutes().length;


           if (iLength>1) {
             this.refs.navigator.pop();
             return true;
           }
           return false;
      });

      codePush.sync();
    }
 componentDidMount() {
   codePush.sync({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE },
     (status) => {
         switch (status) {
           case codePush.SyncStatus.DOWNLOADING_PACKAGE:
             this.setState({status: 'Downloading'});
             break;
           case codePush.SyncStatus.INSTALLING_UPDATE:
             this.setState({status: 'Installing'});
             break;
         }
     },
     ({ receivedBytes, totalBytes, }) => {
       this.setState({receivedBytes, totalBytes});
     }
  );
 }
Exemplo n.º 25
0
 _handleAppStateChange(newState){
   newState === "active" && codePush.sync();
 }
Exemplo n.º 26
0
 componentDidMount() {
     CodePush.sync();
 }
Exemplo n.º 27
0
			shouldSync().done((shouldSync)=>shouldSync && codePush.sync());
Exemplo n.º 28
0
 componentWillMount() {
   codePush.sync( {
     updateDialog: {appendReleaseDescription: true, title: 'An update is available!', optionalIgnoreButtonLabel: 'Not Now', descriptionPrefix: '\nChangelog: \n'},
     installMode: codePush.InstallMode.IMMEDIATE
   });
 }
Exemplo n.º 29
0
 updateBundleByCodePush() {
     let self = this;
     CodePush.sync({
         updateDialog: {// update dialogue
             appendReleaseDescription: true,
             descriptionPrefix: Strings.updateDescription,      // description
             mandatoryContinueButtonLabel: Strings.update,      // mandatory continue
             mandatoryUpdateMessage: Strings.mandatoryUpdate,   // mandatory message
             optionalUpdateMessage: Strings.optionalUpdate,     // optional message
             optionalInstallButtonLabel: Strings.update,        // optional install label
             optionalIgnoreButtonLabel: Strings.ignore,         // optional ignore label
             title: Strings.update,                             // title
         },
         // install mode
         installMode: CodePush.InstallMode.IMMEDIATE
     },
         (status) => { // all status des here https://github.com/Microsoft/react-native-code-push#syncstatus
             console.log('CodePush status = ' + status);
             switch (status) {
                 case CodePush.SyncStatus.DOWNLOADING_PACKAGE: //2
                     // Show "downloading" modal
                     console.log("CodePush Downloading package.");
                     self.setState({
                         updateDlgContent: self.getCodePushUpdateDlg()
                     });
                     self.setUpdateDlgActive(true);
                     break;
                 case CodePush.SyncStatus.INSTALLING_UPDATE: //3
                     // Hide "downloading" modal
                     console.log("CodePush Installing update.");
                     self.setUpdateDlgActive(false);
                     break;
                 case CodePush.SyncStatus.CHECKING_FOR_UPDATE: //0
                     console.log("CodePush Checking for updates.");
                     break;
                 case CodePush.SyncStatus.UP_TO_DATE: //4
                     console.log("CodePush up to date.");
                     break;
                 case CodePush.SyncStatus.UPDATE_IGNORED: //5 
                     console.log("CodePush ignore update.");
                     break;
                 case CodePush.SyncStatus.UPDATE_INSTALLED: //6
                     console.log("CodePush update installed.");
                     break;
                 case CodePush.SyncStatus.UNKNOWN_ERROR: //-1
                     console.log("CodePush unknown error.");
                     break;
             }
         },
         ({ receivedBytes, totalBytes, }) => {
             self.setState({ // receive bytes from server
                 updateDlgContent: self.getCodePushUpdateDlg(),
                 updateReceived: receivedBytes,
                 updateTotal: totalBytes,
             });
             console.log("receivedBytes, totalBytes:" + receivedBytes + ", " + totalBytes);
         }
     );
 }
Exemplo n.º 30
0
 componentDidMount(){
     codePush.sync({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE });
 }