Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
syncAppVersion = () => {
codePush.sync({ mandatoryInstallMode: codePush.InstallMode.IMMEDIATE });
};
componentDidMount() {
CodePush.sync({
deploymentKey: 'lCYb0hSXQUEJHWiSykloC7wXu_19V1dAekTcW',
updateDialog: {
optionalIgnoreButtonLabel: '稍后',
optionalInstallButtonLabel: '后台更新',
optionalUpdateMessage: '“贷贷助手”有新版本了,是否更新?',
title: '更新提示',
},
installMode: CodePush.InstallMode.ON_NEXT_RESTART,
});
}
update () {
codePush.sync({
updateDialog: {
title: '更新',
appendReleaseDescription: true,
descriptionPrefix: '更新内容:\n',
mandatoryContinueButtonLabel: '更新',
mandatoryUpdateMessage: '',
optionalIgnoreButtonLabel: '忽略',
optionalInstallButtonLabel: '更新',
optionalUpdateMessage: '',
},
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
})
}
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);
}
onPress() {
CodePush.sync({
...store.user.codePush,
}, this.codePushStatusDidChange, this.codePushDownloadDidProgress);
}
componentDidMount() {
codePush.sync();
}
onButtonPress() {
codePush.sync({
updateDialog: true,
installMode: codePush.InstallMode.IMMEDIATE
});
}
export default function checkUpdate () {
const options = {
updateDialog: {
appendReleaseDescription: true,
title: '有更新',
descriptionPrefix: '更新内容:',
mandatoryContinueButtonLabel: '继续',
mandatoryUpdateMessage: '必须更新才能继续使用',
optionalIgnoreButtonLabel: '忽略',
optionalInstallButtonLabel: '安装',
optionalUpdateMessage: '有新的版本,你想要安装吗?'
},
installMode: CodePush.InstallMode.IMMEDIATE
}
CodePush.sync(options, status => {
switch (status) {
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
this.refs.nav.push({
component: Loading,
title: ' ',
navigationBarHidden: true,
leftButtonTitle: '',
onLeftButtonPress: () => {}
})
break
case CodePush.SyncStatus.INSTALLING_UPDATE:
break
case CodePush.SyncStatus.AWAITING_USER_ACTION:
break
}
})