vbea пре 3 година
родитељ
комит
5f082b2274

+ 4 - 1
Strides-APP/README.md

@@ -28,9 +28,11 @@ Application ID: com.strides.chargeco
 `yarn add react-native 0.64.0`  
 `yarn add react-native-camera`  
 `//yarn add react-native-cluster-map`  
+`yarn add react-native-code-push@6.4.0`
 `yarn add react-native-device-info`  
 `yarn add react-native-gesture-handler`  
 `yarn add react-native-gradients`  
+`yarn add react-native-i18n`
 `yarn add react-native-image-crop-picker`  
 `//yarn add react-native-image-picker`  
 `yarn add react-native-map-clustering`  
@@ -133,7 +135,8 @@ Application ID: com.strides.chargeco
 [React Native Share](https://react-native-share.github.io/react-native-share/)  
 [RNWebView](https://github.com/react-native-webview/react-native-webview)  
 [react-native-device-info](https://github.com/react-native-device-info/react-native-device-info)  
-
+[微软热更新react-native-code-push](https://learn.microsoft.com/zh-cn/appcenter/distribution/codepush/)  
+[国际化react-native-i18n](https://github.com/AlexanderZaytsev/react-native-i18n)
 
 ## 文章
 https://blog.csdn.net/first_helloword/article/details/109903486  

+ 17 - 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.0.0" //★★★★★版本号★★★★★
+def myVersionName = "2.1.0" //★★★★★版本号★★★★★
 /**
  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  * and bundleReleaseJsAndAssets).
@@ -85,6 +85,7 @@ project.ext.react = [
 
 apply from: "../../node_modules/react-native/react.gradle"
 apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
+apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
 
 /**
  * Set this to true to create two separate APKs instead of one:
@@ -186,6 +187,19 @@ android {
     buildTypes {
         debug {
             signingConfig signingConfigs.debug
+            //热更新应用分发Staging key
+            resValue "string", "CodePushDeploymentKey", "zu0zkOWpBhXTGQ83pC15FW3puB--tuSG5TvIQ"
+        }
+        releaseStaging {
+           signingConfig signingConfigs.release
+            minifyEnabled enableProguardInReleaseBuilds
+            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
+            ndk {
+                abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
+            }
+            //热更新应用分发Staging key
+            resValue "string", "CodePushDeploymentKey", "zu0zkOWpBhXTGQ83pC15FW3puB--tuSG5TvIQ"
+            matchingFallbacks = ['release']
         }
         release {
             // Caution! In production, you need to generate your own keystore file.
@@ -196,6 +210,8 @@ android {
             ndk {
                 abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
             }
+            //热更新应用分发Production key
+            resValue "string", "CodePushDeploymentKey", "rQGN1c2GXKx5EBT1scXipC9xwSQZMG62xiWOd"
         }
     }
 

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

@@ -10,6 +10,8 @@ import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.soloader.SoLoader;
 
+import com.microsoft.codepush.react.CodePush;
+
 import cl.json.ShareApplication;
 
 import java.lang.reflect.InvocationTargetException;
@@ -17,28 +19,32 @@ import java.util.List;
 
 public class MainApplication extends Application implements ShareApplication, ReactApplication {
 
-  private final ReactNativeHost mReactNativeHost =
-      new ReactNativeHost(this) {
-        @Override
-        public boolean getUseDeveloperSupport() {
-          return BuildConfig.DEBUG;
-        }
+  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
+      @Override
+      public boolean getUseDeveloperSupport() {
+        return BuildConfig.DEBUG;
+      }
 
-        @Override
-        protected List<ReactPackage> getPackages() {
-          @SuppressWarnings("UnnecessaryLocalVariable")
-          List<ReactPackage> packages = new PackageList(this).getPackages();
-          // Packages that cannot be autolinked yet can be added manually here, for example:
-          // packages.add(new MyReactNativePackage());
-          //packages.add(new ClusterMapPackage());
-          return packages;
-        }
+      @Override
+      protected List<ReactPackage> getPackages() {
+        @SuppressWarnings("UnnecessaryLocalVariable")
+        List<ReactPackage> packages = new PackageList(this).getPackages();
+        // Packages that cannot be autolinked yet can be added manually here, for example:
+        // packages.add(new MyReactNativePackage());
+        //packages.add(new ClusterMapPackage());
+        return packages;
+      }
 
-        @Override
-        protected String getJSMainModuleName() {
+      @Override
+      protected String getJSMainModuleName() {
           return "index";
-        }
-      };
+      }
+
+      @Override
+      protected String getJSBundleFile() {
+          return CodePush.getJSBundleFile();
+      }
+  };
 
   @Override
   public ReactNativeHost getReactNativeHost() {

+ 2 - 1
Strides-APP/android/settings.gradle

@@ -1,6 +1,7 @@
 rootProject.name = 'JuicePlus'
 apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
 applyNativeModulesSettingsGradle(settings)
-include ':app'
+include ':app', ':react-native-code-push'
+project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
 // include ':react-native-maps'
 // project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

+ 2 - 2
Strides-APP/app.json

@@ -1,8 +1,8 @@
 {
   "name": "JuicePlus",
   "displayName": "ChargEco",
-  "versionCode": 90,
-  "versionName": "V2.0.0",
+  "versionCode": 110,
+  "versionName": "V2.1.0",
   "product": false,
   "debug": false
 }

+ 3 - 3
Strides-APP/app/pages/sign/ResetPasswordV2.js

@@ -38,9 +38,9 @@ export default class ResetPassword extends Component {
     const action = this.props.route?.params?.action ?? "";
     if (action == "change") {
       this.isChange = true;
-      setTimeout(() => {
+      /*setTimeout(() => {
         this.requestLogout();
-      }, 1000);
+      }, 1000);*/
     }
   }
 
@@ -162,7 +162,7 @@ export default class ResetPassword extends Component {
       if (this.isChange) {
         this.requestLogout();
       } else {
-       goBack();
+        goBack();
       }
     }).catch(err => {
       Dialog.dismissLoading()

+ 11 - 1
Strides-APP/index.js

@@ -3,6 +3,7 @@
  */
 import React 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';
@@ -31,4 +32,13 @@ const Index = () => {
   );
 };
 
-AppRegistry.registerComponent(appName, () => Index);
+//热更新配置
+let codePushOptions = {
+  //实时检测更新并下载
+  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
+  //下载完成后立即安装
+  installMode: codePush.InstallMode.IMMEDIATE
+};
+
+AppRegistry.registerComponent(appName, () => codePush(codePushOptions)(Index));
+//AppRegistry.registerComponent(appName, () => Index);

+ 3 - 1
Strides-APP/ios/JuicePlus/AppDelegate.m

@@ -7,6 +7,7 @@
 
 #import <UserNotifications/UserNotifications.h>
 #import <RNCPushNotificationIOS.h>
+#import <CodePush/CodePush.h>
 
 #ifdef FB_SONARKIT_ENABLED
 #import <FlipperKit/FlipperClient.h>
@@ -152,7 +153,8 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
   #if DEBUG
     return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
   #else
-    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+    //return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+    return [CodePush bundleURL];
   #endif
 }
 

+ 2 - 0
Strides-APP/ios/JuicePlus/Info.plist

@@ -121,5 +121,7 @@
 	</array>
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<false/>
+	<key>CodePushDeploymentKey</key>
+	<string>EFE-MvoErACkxH3PJWA0r1lW4joZ7GniqRdHg</string>
 </dict>
 </plist>

+ 2 - 0
Strides-APP/ios/Podfile

@@ -33,6 +33,8 @@ target 'JuicePlus' do
   pod 'Firebase/Messaging', :modular_headers => true
   pod 'FirebaseCoreInternal', :modular_headers => true
   pod 'GoogleUtilities', :modular_headers => true
+  #微软热更新
+  pod 'CodePush', :path => '../node_modules/react-native-code-push'
 
   use_react_native!(
     :path => config[:reactNativePath],

+ 7 - 2
Strides-APP/package.json

@@ -1,6 +1,6 @@
 {
   "name": "strides",
-  "version": "1.0.0",
+  "version": "2.0.0",
   "license": "MIT",
   "private": true,
   "scripts": {
@@ -15,7 +15,11 @@
     "build:ios": "react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/bundle/main.jsbundle --assets-dest ios/bundle ",
     "clean": "cd android & ./gradlew clean",
     "apk": "cd android & ./gradlew assembleRelease",
-    "reset": "react-native start --reset-cache"
+    "reset": "react-native start --reset-cache",
+    "sit:android": "appcenter codepush release-react -a vbe/ChargEcoAndroid -d Staging -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",
+    "prod:ios": "appcenter codepush release-react -a vbe/ChargEcoiOS -d Production -t"
   },
   "dependencies": {
     "@react-native-async-storage/async-storage": "^1.15.3",
@@ -33,6 +37,7 @@
     "react": "17.0.1",
     "react-native": "0.64.2",
     "react-native-camera": "^3.43.5",
+    "react-native-code-push": "6.4.1",
     "react-native-device-info": "^8.3.1",
     "react-native-gesture-handler": "^1.10.3",
     "react-native-gradients": "^1.1.1",