|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
/**
|
|
|
* @format
|
|
* @format
|
|
|
*/
|
|
*/
|
|
|
-import React, { useEffect } from 'react';
|
|
|
|
|
|
|
+import React from 'react';
|
|
|
import {AppRegistry, KeyboardAvoidingView, StatusBar} from 'react-native';
|
|
import {AppRegistry, KeyboardAvoidingView, StatusBar} from 'react-native';
|
|
|
import codePush from "react-native-code-push";
|
|
import codePush from "react-native-code-push";
|
|
|
import 'react-native-gesture-handler';
|
|
import 'react-native-gesture-handler';
|
|
@@ -10,20 +10,13 @@ import './app/utils/constant';
|
|
|
import './app/utils/notification';
|
|
import './app/utils/notification';
|
|
|
import './app/utils/vector_icon';
|
|
import './app/utils/vector_icon';
|
|
|
import Router from './app/pages/Router';
|
|
import Router from './app/pages/Router';
|
|
|
-import app from './app.json';
|
|
|
|
|
|
|
+import {name as appName} from './app.json';
|
|
|
//import {ModalPortal} from 'react-native-modals';
|
|
//import {ModalPortal} from 'react-native-modals';
|
|
|
import ModalPortal from './app/components/ModalPortal';
|
|
import ModalPortal from './app/components/ModalPortal';
|
|
|
import {RootSiblingParent} from 'react-native-root-siblings';
|
|
import {RootSiblingParent} from 'react-native-root-siblings';
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
-import Analytics from 'appcenter-analytics';
|
|
|
|
|
|
|
|
|
|
const Index = () => {
|
|
const Index = () => {
|
|
|
- useEffect(() => {
|
|
|
|
|
- Analytics.trackEvent("IntoApp", {versionName: app.versionName, versionCode: app.versionCode});
|
|
|
|
|
- if (isIos) {
|
|
|
|
|
- checkUpdate();
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
return (
|
|
return (
|
|
|
<RootSiblingParent>
|
|
<RootSiblingParent>
|
|
|
<StatusBar barStyle={themeStatusBar} backgroundColor={colorPrimaryDark}/>
|
|
<StatusBar barStyle={themeStatusBar} backgroundColor={colorPrimaryDark}/>
|
|
@@ -39,69 +32,15 @@ const Index = () => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const checkUpdate = () => {
|
|
|
|
|
- console.log("[CodePush]", "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]", "Downloading update");
|
|
|
|
|
- break;
|
|
|
|
|
- case codePush.SyncStatus.INSTALLING_UPDATE:
|
|
|
|
|
- if (app.debug) {
|
|
|
|
|
- toastShort("Installing update")
|
|
|
|
|
- }
|
|
|
|
|
- console.log("[CodePush]", "Installing update");
|
|
|
|
|
- break;
|
|
|
|
|
- case codePush.SyncStatus.UP_TO_DATE:
|
|
|
|
|
- if (app.debug) {
|
|
|
|
|
- toastShort("App is up to date")
|
|
|
|
|
- }
|
|
|
|
|
- console.log("[CodePush]", "App is up to date");
|
|
|
|
|
- codePush.notifyAppReady();
|
|
|
|
|
- break;
|
|
|
|
|
- case codePush.SyncStatus.UPDATE_INSTALLED:
|
|
|
|
|
- if (app.debug) {
|
|
|
|
|
- toastShort("Update installed")
|
|
|
|
|
- }
|
|
|
|
|
- console.log("[CodePush]", "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: true,
|
|
|
|
|
|
|
+let codePushOptions = {
|
|
|
//实时检测更新并下载
|
|
//实时检测更新并下载
|
|
|
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
|
|
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
|
|
|
//下载完成后立即安装
|
|
//下载完成后立即安装
|
|
|
- installMode: codePush.InstallMode.IMMEDIATE
|
|
|
|
|
|
|
+ //installMode: codePush.InstallMode.IMMEDIATE,
|
|
|
//下次进入安装
|
|
//下次进入安装
|
|
|
- //installMode: codePush.InstallMode.ON_NEXT_RESTART
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ installMode: codePush.InstallMode.ON_NEXT_RESTART
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
-AppRegistry.registerComponent(app.name, () => codePush(isIOS ? codePushIos : codePushAndroid)(Index));
|
|
|
|
|
|
|
+AppRegistry.registerComponent(appName, () => codePush(codePushOptions)(Index));
|
|
|
//AppRegistry.registerComponent(appName, () => Index);
|
|
//AppRegistry.registerComponent(appName, () => Index);
|