/** * @format */ import React, { useEffect } from 'react'; import {AppRegistry, KeyboardAvoidingView, StatusBar} from 'react-native'; import codePush from "react-native-code-push"; import 'react-native-gesture-handler'; import './app/utils/themes' import './app/utils/constant'; import './app/utils/notification'; import './app/utils/vector_icon'; import Router from './app/pages/Router'; import app from './app.json'; //import {ModalPortal} from 'react-native-modals'; import ModalPortal from './app/components/ModalPortal'; import {RootSiblingParent} from 'react-native-root-siblings'; import { SafeAreaView } from 'react-native-safe-area-context'; const Index = () => { useEffect(() => { //Analytics.trackEvent("IntoApp", {versionName: app.versionName, versionCode: app.versionCode}); if (isIOS) { checkUpdate(); } }) return ( { isIOS ? : } ); }; const checkUpdate = () => { console.log("[CodePush-iOS]", "Checking Update"); //Analytics.trackEvent('checkUpdate', { versionName: app.versionName, versionCode: app.versionCode }); //codePush.disallowRestart(); codePush.sync({ updateDialog: app.debug, installMode: codePush.InstallMode.IMMEDIATE }, status => { //Analytics.trackEvent('checkUpdate-status', status); switch(status) { case codePush.SyncStatus.DOWNLOADING_PACKAGE: if (app.debug) { toastShort("Downloading update...") } console.log("[CodePush-iOS]", "Downloading update"); break; case codePush.SyncStatus.INSTALLING_UPDATE: if (app.debug) { toastShort("Installing update") } console.log("[CodePush-iOS]", "Installing update"); break; case codePush.SyncStatus.UP_TO_DATE: if (app.debug) { toastShort("App is up to date") } console.log("[CodePush-iOS]", "App is up to date"); codePush.notifyAppReady(); break; case codePush.SyncStatus.UPDATE_INSTALLED: if (app.debug) { toastShort("Update installed") } console.log("[CodePush-iOS]", "Update installed"); codePush.notifyAppReady(); //codePush.restartApp(true); break; } }, process => { }); } //热更新配置 let codePushIos = { updateDialog: true, //实时检测更新并下载 checkFrequency: codePush.CheckFrequency.MANUAL, //下载完成后立即安装 //installMode: codePush.InstallMode.IMMEDIATE //下次进入安装 //installMode: codePush.InstallMode.ON_NEXT_RESTART }; let codePushAndroid = { updateDialog: false, //实时检测更新并下载 checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, //下载完成后立即安装 installMode: codePush.InstallMode.IMMEDIATE //下次进入安装 //installMode: codePush.InstallMode.ON_NEXT_RESTART } AppRegistry.registerComponent(app.name, () => codePush(isIOS ? codePushIos : codePushAndroid)(Index)); //AppRegistry.registerComponent(appName, () => Index);