vbea vor 3 Jahren
Ursprung
Commit
114b28a9c7

+ 1 - 1
Strides-APP/android/app/build.gradle

@@ -3,7 +3,7 @@ apply plugin: 'com.google.gms.google-services'
 
 import com.android.build.OutputFile
 
-def myVersionName = "2.1.2" //★★★★★版本号★★★★★
+def myVersionName = "2.2.0" //★★★★★版本号★★★★★
 /**
  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  * and bundleReleaseJsAndAssets).

+ 2 - 2
Strides-APP/android/app/version.properties

@@ -1,2 +1,2 @@
-#Tue Feb 14 18:42:27 CST 2023
-VERSION_CODE=149
+#Tue Feb 14 20:36:46 CST 2023
+VERSION_CODE=179

+ 67 - 7
Strides-APP/index.js

@@ -1,7 +1,7 @@
 /**
  * @format
  */
-import React from 'react';
+import React, { useEffect } from 'react';
 import {AppRegistry, KeyboardAvoidingView, StatusBar} from 'react-native';
 import codePush from "react-native-code-push";
 import 'react-native-gesture-handler';
@@ -10,13 +10,19 @@ import './app/utils/constant';
 import './app/utils/notification';
 import './app/utils/vector_icon';
 import Router from './app/pages/Router';
-import {name as appName} from './app.json';
+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 (
     <RootSiblingParent>
       <StatusBar barStyle={themeStatusBar} backgroundColor={colorPrimaryDark}/>
@@ -32,15 +38,69 @@ const Index = () => {
   );
 };
 
+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 codePushOptions = {
+let codePushIos = {
+  updateDialog: true,
   //实时检测更新并下载
-  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
+  checkFrequency: codePush.CheckFrequency.MANUAL,
   //下载完成后立即安装
-  //installMode: codePush.InstallMode.IMMEDIATE,
+  //installMode: codePush.InstallMode.IMMEDIATE
   //下次进入安装
-  installMode: codePush.InstallMode.ON_NEXT_RESTART
+  //installMode: codePush.InstallMode.ON_NEXT_RESTART
 };
 
-AppRegistry.registerComponent(appName, () => codePush(codePushOptions)(Index));
+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);

+ 0 - 3
Strides-APP/ios/Podfile

@@ -35,9 +35,6 @@ target 'JuicePlus' do
   pod 'GoogleUtilities', :modular_headers => true
   #微软热更新
   pod 'CodePush', :path => '../node_modules/react-native-code-push'
-  pod 'AppCenter', :modular_headers => true
-  pod 'AppCenter/Analytics', :modular_headers => true
-  pod 'AppCenter/Crashes', :modular_headers => true
 
   use_react_native!(
     :path => config[:reactNativePath],

+ 0 - 3
Strides-APP/package.json

@@ -35,9 +35,6 @@
     "@react-navigation/material-top-tabs": "^5.3.19",
     "@react-navigation/native": "^5.9.4",
     "@react-navigation/stack": "^5.14.4",
-    "appcenter": "^4.4.5",
-    "appcenter-analytics": "^4.4.5",
-    "appcenter-crashes": "^4.4.5",
     "axios": "^0.21.1",
     "react": "17.0.1",
     "react-native": "https://gitee.com/vbes/react-native.git",