Răsfoiți Sursa

add appcenter

vbea 3 ani în urmă
părinte
comite
7046357e59

+ 2 - 0
Strides-APP/android/app/build.gradle

@@ -80,6 +80,8 @@ def myVersionName = "2.1.2" //★★★★★版本号★★★★★
  */
  */
 
 
 project.ext.react = [
 project.ext.react = [
+    entryFile: "index.js",
+    //hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes", // Or whatever path you need
     enableHermes: true,  // clean and rebuild if changing
     enableHermes: true,  // clean and rebuild if changing
 ]
 ]
 
 

+ 3 - 0
Strides-APP/android/app/src/main/assets/appcenter-config.json

@@ -0,0 +1,3 @@
+{
+  "app_secret": "281c5133-a65f-4eff-962f-cb548267b006"
+}

+ 2 - 2
Strides-APP/android/app/src/main/java/com/strides/chargeco/MainApplication.java

@@ -35,10 +35,10 @@ public class MainApplication extends Application implements ShareApplication, Re
         return packages;
         return packages;
       }
       }
 
 
-      @Override
+      /*@Override
       protected String getJSMainModuleName() {
       protected String getJSMainModuleName() {
           return "index";
           return "index";
-      }
+      }*/
 
 
       @Override
       @Override
       protected String getJSBundleFile() {
       protected String getJSBundleFile() {

+ 2 - 0
Strides-APP/android/app/src/main/res/values/strings.xml

@@ -1,4 +1,6 @@
 <resources>
 <resources>
     <string name="app_name">ChargEco</string>
     <string name="app_name">ChargEco</string>
     <string name="default_notification_channel_id">10186</string>
     <string name="default_notification_channel_id">10186</string>
+    <string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false">DO_NOT_ASK_JAVASCRIPT</string>
+    <string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false">ALWAYS_SEND</string>
 </resources>
 </resources>

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

@@ -1,2 +1,2 @@
-#Tue Feb 14 14:22:46 CST 2023
-VERSION_CODE=123
+#Tue Feb 14 17:36:03 CST 2023
+VERSION_CODE=138

+ 3 - 3
Strides-APP/app.json

@@ -1,8 +1,8 @@
 {
 {
   "name": "JuicePlus",
   "name": "JuicePlus",
   "displayName": "ChargEco",
   "displayName": "ChargEco",
-  "versionCode": 112,
-  "versionName": "V2.1.1",
+  "versionCode": 115,
+  "versionName": "V2.1.2",
   "product": false,
   "product": false,
-  "debug": false
+  "debug": true
 }
 }

BIN
Strides-APP/app/images/user/bg-vehicles.png


+ 44 - 36
Strides-APP/app/pages/my/VehicleList.js

@@ -3,7 +3,7 @@
  * @邠心vbe on 2021/06/08
  * @邠心vbe on 2021/06/08
  */
  */
 import React, { Component } from 'react';
 import React, { Component } from 'react';
-import { View, Text, ImageBackground, Image, StyleSheet, Pressable } from 'react-native';
+import { View, Text, Image, StyleSheet, Pressable } from 'react-native';
 import apiUser from '../../api/apiUser';
 import apiUser from '../../api/apiUser';
 import { ElevationObject } from '../../components/Button';
 import { ElevationObject } from '../../components/Button';
 import Dialog from '../../components/Dialog';
 import Dialog from '../../components/Dialog';
@@ -91,6 +91,7 @@ export default class VehicleList extends Component {
         return (
         return (
           <Pressable
           <Pressable
             key={index}
             key={index}
+            style={styles.vehicleView}
             onPress={() => {
             onPress={() => {
               startPage(PageList.editVehicle, {id: item.vehiclePk});
               startPage(PageList.editVehicle, {id: item.vehiclePk});
             }}
             }}
@@ -100,42 +101,40 @@ export default class VehicleList extends Component {
               } else {
               } else {
                 this.removeVehicle(item.vehiclePk)
                 this.removeVehicle(item.vehiclePk)
               }
               }
-            }}
-            style={$padding(16, 16, 0)}>
-            <ImageBackground
-              style={styles.vehicleView}
+            }}>
+            <Image
               resizeMode="contain"
               resizeMode="contain"
-              source={require('../../images/user/bg-vehicles.png')}>
-              <View style={styles.vehicleRow}>
-                <Image
-                  style={styles.vehicleIcon}
-                  source={require('../../images/user/ic-vehicle-model.png')}/>
-                <Text style={styles.vehicleName}>{item.brand} {item.model}</Text>
-              </View>
-              <Text style={styles.vehicleModle}>{item.licensePlate}</Text>
-              <View style={styles.vehicleRow}>
-                <View style={styles.vehicleTypeRow}>
-                  <View style={styles.vehicleTypeIcon}>
-                    <VehicleType size={10}/>
-                  </View>
-                  <Text style={styles.vehicleType}>TYPE {item.connectorType}</Text>
+              style={styles.vehicleViewBg}
+              source={require('../../images/user/bg-vehicles.png')}/>
+            <View style={styles.vehicleRow}>
+              <Image
+                style={styles.vehicleIcon}
+                source={require('../../images/user/ic-vehicle-model.png')}/>
+              <Text style={styles.vehicleName}>{item.brand} {item.model}</Text>
+            </View>
+            <Text style={styles.vehicleModle}>{item.licensePlate}</Text>
+            <View style={styles.vehicleRow}>
+              <View style={styles.vehicleTypeRow}>
+                <View style={styles.vehicleTypeIcon}>
+                  <VehicleType size={10}/>
                 </View>
                 </View>
-                {/* <Image
-                  style={styles.vehicleIcon}
-                  source={type?.icon}/>
-                <Text style={styles.vehicleName}>{type?.name}</Text> */}
+                <Text style={styles.vehicleType}>TYPE {item.connectorType}</Text>
               </View>
               </View>
-              <Pressable
-                style={styles.closeIcon}
-                android_ripple={rippleLess}
-                onPress={() => this.removeVehicle(item.vehiclePk)}>
-                <MaterialCommunityIcons
-                  name="close"
-                  size={20}
-                  color={textCancel}
-                />
-              </Pressable>
-            </ImageBackground>
+              {/* <Image
+                style={styles.vehicleIcon}
+                source={type?.icon}/>
+              <Text style={styles.vehicleName}>{type?.name}</Text> */}
+            </View>
+            <Pressable
+              style={styles.closeIcon}
+              android_ripple={rippleLess}
+              onPress={() => this.removeVehicle(item.vehiclePk)}>
+              <MaterialCommunityIcons
+                name="close"
+                size={20}
+                color={textCancel}
+              />
+            </Pressable>
           </Pressable>
           </Pressable>
         );
         );
       })
       })
@@ -146,10 +145,19 @@ export default class VehicleList extends Component {
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
   vehicleView: {
   vehicleView: {
-    ...$padding(12, 16, 20),
     borderRadius: 8,
     borderRadius: 8,
     overflow: 'hidden',
     overflow: 'hidden',
-    ...ElevationObject(5)
+    ...ElevationObject(5),
+    ...$margin(16, 16, 0),
+    ...$padding(12, 16, 20),
+    backgroundColor: colorLight
+  },
+  vehicleViewBg: {
+    right: 8,
+    bottom: 8,
+    width: 111,
+    height: 54,
+    position: 'absolute'
   },
   },
   vehicleRow: {
   vehicleRow: {
     alignItems: 'center',
     alignItems: 'center',

+ 53 - 6
Strides-APP/index.js

@@ -1,7 +1,7 @@
 /**
 /**
  * @format
  * @format
  */
  */
-import React from 'react';
+import React, { useEffect } 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,13 +10,17 @@ 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 {name as appName} from './app.json';
+import app 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(() => {
+    checkUpdate();
+  })
   return (
   return (
     <RootSiblingParent>
     <RootSiblingParent>
       <StatusBar barStyle={themeStatusBar} backgroundColor={colorPrimaryDark}/>
       <StatusBar barStyle={themeStatusBar} backgroundColor={colorPrimaryDark}/>
@@ -32,16 +36,59 @@ 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 codePushOptions = {
 let codePushOptions = {
-  updateDialog: true,
+  updateDialog: isIOS,
   //实时检测更新并下载
   //实时检测更新并下载
-  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));
+AppRegistry.registerComponent(app.name, () => codePush(codePushOptions)(Index));
 //AppRegistry.registerComponent(appName, () => Index);
 //AppRegistry.registerComponent(appName, () => Index);

+ 8 - 0
Strides-APP/ios/JuicePlus/AppCenter-Config.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+    <key>AppSecret</key>
+    <string>07724e75-a219-4a90-9377-7e3b135dd508</string>
+    </dict>
+</plist>

+ 8 - 0
Strides-APP/ios/JuicePlus/AppDelegate.m

@@ -7,6 +7,9 @@
 
 
 #import <UserNotifications/UserNotifications.h>
 #import <UserNotifications/UserNotifications.h>
 #import <RNCPushNotificationIOS.h>
 #import <RNCPushNotificationIOS.h>
+#import <AppCenterReactNative.h>
+#import <AppCenterReactNativeAnalytics.h>
+#import <AppCenterReactNativeCrashes.h>
 #import <CodePush/CodePush.h>
 #import <CodePush/CodePush.h>
 
 
 #ifdef FB_SONARKIT_ENABLED
 #ifdef FB_SONARKIT_ENABLED
@@ -60,6 +63,11 @@ static void InitializeFlipper(UIApplication *application) {
   //谷歌地图配置
   //谷歌地图配置
   [GMSServices provideAPIKey:@"AIzaSyAVzs860l2Iuu1zG80IT1Zu4w7OvbVmJ4g"]; // add this line using the api key obtained from Google Console
   [GMSServices provideAPIKey:@"AIzaSyAVzs860l2Iuu1zG80IT1Zu4w7OvbVmJ4g"]; // add this line using the api key obtained from Google Console
 
 
+  //AppCenter设置
+  [AppCenterReactNative register];
+  [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];
+  [AppCenterReactNativeCrashes registerWithAutomaticProcessing];
+  
   //远程推送配置
   //远程推送配置
   // Define UNUserNotificationCenter
   // Define UNUserNotificationCenter
   UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
   UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];

+ 5 - 1
Strides-APP/package.json

@@ -20,6 +20,7 @@
     "prod:android": "appcenter codepush release-react -a vbe/ChargEcoAndroid -d Production -t",
     "prod:android": "appcenter codepush release-react -a vbe/ChargEcoAndroid -d Production -t",
     "sit:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -d Staging -t",
     "sit:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -d Staging -t",
     "prod:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -d Production -t",
     "prod:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -d Production -t",
+    "push:android": "appcenter codepush release-react -a vbe/ChargEcoAndroid -d Production -t",
     "push:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -c ios/bundle -d Production -t"
     "push:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -c ios/bundle -d Production -t"
   },
   },
   "dependencies": {
   "dependencies": {
@@ -34,9 +35,12 @@
     "@react-navigation/material-top-tabs": "^5.3.19",
     "@react-navigation/material-top-tabs": "^5.3.19",
     "@react-navigation/native": "^5.9.4",
     "@react-navigation/native": "^5.9.4",
     "@react-navigation/stack": "^5.14.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",
     "axios": "^0.21.1",
     "react": "17.0.1",
     "react": "17.0.1",
-    "react-native": "0.64.2",
+    "react-native": "https://gitee.com/vbes/react-native.git",
     "react-native-camera": "^3.43.5",
     "react-native-camera": "^3.43.5",
     "react-native-code-push": "^7.1.0",
     "react-native-code-push": "^7.1.0",
     "react-native-device-info": "^8.3.1",
     "react-native-device-info": "^8.3.1",