diff --git a/client/mobile/.env.example b/client/mobile/.env.example
new file mode 100644
index 00000000..3b3848e8
--- /dev/null
+++ b/client/mobile/.env.example
@@ -0,0 +1,3 @@
+GETUI_APPID=
+GETUI_APPKEY=
+GETUI_APPSECRET=
diff --git a/client/mobile/android/app/build.gradle b/client/mobile/android/app/build.gradle
index c1eed48a..a82fb86f 100644
--- a/client/mobile/android/app/build.gradle
+++ b/client/mobile/android/app/build.gradle
@@ -1,5 +1,6 @@
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
+apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
@@ -100,6 +101,10 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
+
+ manifestPlaceholders = [
+ GETUI_APPID: project.env.get("GETUI_APPID"),
+ ]
}
splits {
diff --git a/client/mobile/android/app/src/debug/AndroidManifest.xml b/client/mobile/android/app/src/debug/AndroidManifest.xml
index 4b185bc1..2da469b9 100644
--- a/client/mobile/android/app/src/debug/AndroidManifest.xml
+++ b/client/mobile/android/app/src/debug/AndroidManifest.xml
@@ -10,4 +10,9 @@
tools:ignore="GoogleAppIndexingWarning">
+
+
+
+
+
diff --git a/client/mobile/android/app/src/main/AndroidManifest.xml b/client/mobile/android/app/src/main/AndroidManifest.xml
index 4122f36a..f0c07478 100644
--- a/client/mobile/android/app/src/main/AndroidManifest.xml
+++ b/client/mobile/android/app/src/main/AndroidManifest.xml
@@ -21,5 +21,10 @@
+
+
+
+
+
diff --git a/client/mobile/android/app/src/main/java/com/tailchat/MainApplication.java b/client/mobile/android/app/src/main/java/com/tailchat/MainApplication.java
index 9cc6f803..6c115be6 100644
--- a/client/mobile/android/app/src/main/java/com/tailchat/MainApplication.java
+++ b/client/mobile/android/app/src/main/java/com/tailchat/MainApplication.java
@@ -9,6 +9,7 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.util.List;
+import com.getui.reactnativegetui.GetuiModule;
public class MainApplication extends Application implements ReactApplication {
@@ -53,6 +54,7 @@ public class MainApplication extends Application implements ReactApplication {
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
+ GetuiModule.initPush(this);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
diff --git a/client/mobile/android/build.gradle b/client/mobile/android/build.gradle
index 67d887b0..16d34143 100644
--- a/client/mobile/android/build.gradle
+++ b/client/mobile/android/build.gradle
@@ -19,3 +19,14 @@ buildscript {
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
+
+allprojects {
+ repositories {
+ maven {
+ url "https://mvn.getui.com/nexus/content/repositories/releases/"
+ }
+
+ google()
+ mavenCentral()
+ }
+}
diff --git a/client/mobile/android/settings.gradle b/client/mobile/android/settings.gradle
index 1b14c8de..c8e6b51c 100644
--- a/client/mobile/android/settings.gradle
+++ b/client/mobile/android/settings.gradle
@@ -1,4 +1,6 @@
rootProject.name = 'Tailchat'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
-include ':app'
+include ':app', ':react-native-getui'
+project(':react-native-getui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-getui/android')
+
includeBuild('../node_modules/react-native-gradle-plugin')
diff --git a/client/mobile/ios/Podfile.lock b/client/mobile/ios/Podfile.lock
index f7f8cb09..9e1f83b3 100644
--- a/client/mobile/ios/Podfile.lock
+++ b/client/mobile/ios/Podfile.lock
@@ -73,6 +73,11 @@ PODS:
- FlipperKit/FlipperKitNetworkPlugin
- fmt (6.2.1)
- glog (0.3.5)
+ - GTSDK (2.7.4.0):
+ - ZXSDK
+ - GtSdkRN (1.1.42):
+ - GTSDK
+ - React
- hermes-engine (0.71.2):
- hermes-engine/Pre-built (= 0.71.2)
- hermes-engine/Pre-built (0.71.2)
@@ -329,6 +334,10 @@ PODS:
- React-jsinspector (0.71.2)
- React-logger (0.71.2):
- glog
+ - react-native-config (1.5.0):
+ - react-native-config/App (= 1.5.0)
+ - react-native-config/App (1.5.0):
+ - React-Core
- react-native-webview (11.26.1):
- React-Core
- React-perflogger (0.71.2)
@@ -457,6 +466,7 @@ PODS:
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
+ - ZXSDK (3.2.3)
DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
@@ -485,6 +495,7 @@ DEPENDENCIES:
- FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0)
- FlipperKit/SKIOSNetworkPlugin (= 0.125.0)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
+ - GtSdkRN (from `../node_modules/react-native-getui`)
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- libevent (~> 2.1.12)
- OpenSSL-Universal (= 1.1.1100)
@@ -504,6 +515,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
+ - react-native-config (from `../node_modules/react-native-config`)
- react-native-webview (from `../node_modules/react-native-webview`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
@@ -538,10 +550,12 @@ SPEC REPOS:
- Flipper-RSocket
- FlipperKit
- fmt
+ - GTSDK
- libevent
- OpenSSL-Universal
- SocketRocket
- YogaKit
+ - ZXSDK
EXTERNAL SOURCES:
boost:
@@ -554,6 +568,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/React/FBReactNativeSpec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
+ GtSdkRN:
+ :path: "../node_modules/react-native-getui"
hermes-engine:
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
RCT-Folly:
@@ -584,6 +600,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
+ react-native-config:
+ :path: "../node_modules/react-native-config"
react-native-webview:
:path: "../node_modules/react-native-webview"
React-perflogger:
@@ -642,6 +660,8 @@ SPEC CHECKSUMS:
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
+ GTSDK: f28e6d575e8a1c26e331ce29b0ecac7db39679cc
+ GtSdkRN: d43bf94df00093d6a19a071080743cb4519bedd1
hermes-engine: 6351580c827b3b03e5f25aadcf989f582d0b0a86
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
@@ -659,6 +679,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7e028406112db456ac3cf5720d266bc7bc20938
React-jsinspector: ea8101acf525ec08b2d87ddf0637d45f8e3b4148
React-logger: 97987f46779d8dd24656474ad0c43a5b459f31d6
+ react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
react-native-webview: 9f111dfbcfc826084d6c507f569e5e03342ee1c1
React-perflogger: c7ccda3d1d1da837f7ff4e54e816022a6803ee87
React-RCTActionSheet: 01c125aebbad462a24228f68c584c7a921d6c28e
@@ -681,6 +702,7 @@ SPEC CHECKSUMS:
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: 5b0304b3dbef2b52e078052138e23a19c7dacaef
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
+ ZXSDK: 3ae8f7f2c5d45b4c1def43e14d930495c5f4d424
PODFILE CHECKSUM: 9aaf3e7752d79b6a889333eec3c3b53e8133916b
diff --git a/client/mobile/ios/Tailchat/AppDelegate.h b/client/mobile/ios/Tailchat/AppDelegate.h
index 5d280825..fd40ab89 100644
--- a/client/mobile/ios/Tailchat/AppDelegate.h
+++ b/client/mobile/ios/Tailchat/AppDelegate.h
@@ -1,5 +1,13 @@
#import
#import
+#if __has_include()
+#import
+#elif __has_include("RCTGetuiModule.h")
+#import "RCTGetuiModule.h"
+#elif __has_include()
+#import
+#endif
+
@interface AppDelegate : RCTAppDelegate
diff --git a/client/mobile/ios/Tailchat/AppDelegate.mm b/client/mobile/ios/Tailchat/AppDelegate.mm
index 5287564e..e57004e1 100644
--- a/client/mobile/ios/Tailchat/AppDelegate.mm
+++ b/client/mobile/ios/Tailchat/AppDelegate.mm
@@ -1,4 +1,5 @@
#import "AppDelegate.h"
+#import "RNCConfig.h"
#import
@@ -6,6 +7,11 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
+ // 接入个推
+ [GeTuiSdk startSdkWithAppId:[RNCConfig envFor:@"GETUI_APPID"] appKey:[RNCConfig envFor:@"GETUI_APPKEY"] appSecret:[RNCConfig envFor:@"GETUI_APPSECRET"] delegate:[RCTGetuiModule sharedGetuiModule] launchingOptions:launchOptions];
+ // APNs
+ [GeTuiSdk registerRemoteNotification: (UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)];
+
self.moduleName = @"Tailchat";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
diff --git a/client/mobile/package.json b/client/mobile/package.json
index 3978bb8a..d166184e 100644
--- a/client/mobile/package.json
+++ b/client/mobile/package.json
@@ -18,7 +18,9 @@
"mini-star": "^2.0.8",
"react": "18.2.0",
"react-native": "0.71.2",
+ "react-native-config": "^1.5.0",
"react-native-gesture-handler": "^2.9.0",
+ "react-native-getui": "^1.1.42",
"react-native-reanimated": "^2.14.4",
"react-native-ui-lib": "^6.29.1",
"react-native-webview": "^11.26.1",
diff --git a/client/mobile/src/lib/inject/message-handler.ts b/client/mobile/src/lib/inject/message-handler.ts
index 22335599..ab0dcd3a 100644
--- a/client/mobile/src/lib/inject/message-handler.ts
+++ b/client/mobile/src/lib/inject/message-handler.ts
@@ -39,6 +39,7 @@ export function handleTailchatMessage(
const userInfo = payload.userInfo as UserBaseInfo;
initNotificationEnv({
+ userId: userInfo._id,
nickname: userInfo.nickname ?? userInfo.email,
runService: () => {
createSocket(serviceUrl, token).then((socket) => {
diff --git a/client/mobile/src/lib/notifications/getui.ts b/client/mobile/src/lib/notifications/getui.ts
new file mode 100644
index 00000000..79e932f3
--- /dev/null
+++ b/client/mobile/src/lib/notifications/getui.ts
@@ -0,0 +1,9 @@
+import Getui from 'react-native-getui';
+
+/**
+ * bind alias with userId
+ * user for server push
+ */
+export function bindAlias(userId: string) {
+ Getui.bindAlias(userId);
+}
diff --git a/client/mobile/src/lib/notifications/index.ts b/client/mobile/src/lib/notifications/index.ts
index bc3362a7..48926977 100644
--- a/client/mobile/src/lib/notifications/index.ts
+++ b/client/mobile/src/lib/notifications/index.ts
@@ -1,4 +1,5 @@
import notifee, { EventType } from '@notifee/react-native';
+import { bindAlias } from './getui';
interface NotificationInfo {
title: string;
@@ -43,15 +44,19 @@ export async function showNotification(info: NotificationInfo) {
}
interface NotificationOptions {
+ userId: string;
nickname: string;
runService: () => void;
}
export async function initNotificationEnv(options: NotificationOptions) {
await notifee.requestPermission();
- await initForegroundService(options);
+ bindAlias(options.userId);
+
+ // await initForegroundService(options);
}
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function initForegroundService(options: NotificationOptions) {
notifee.registerForegroundService((_notification) => {
return new Promise(() => {
diff --git a/client/mobile/types/index.d.ts b/client/mobile/types/index.d.ts
new file mode 100644
index 00000000..cf021fe5
--- /dev/null
+++ b/client/mobile/types/index.d.ts
@@ -0,0 +1 @@
+declare module 'react-native-getui';
diff --git a/client/mobile/yarn.lock b/client/mobile/yarn.lock
index c7ed1d50..ac036661 100644
--- a/client/mobile/yarn.lock
+++ b/client/mobile/yarn.lock
@@ -6976,6 +6976,11 @@ react-native-codegen@^0.71.3:
jscodeshift "^0.13.1"
nullthrows "^1.1.1"
+react-native-config@^1.5.0:
+ version "1.5.0"
+ resolved "https://registry.npmmirror.com/react-native-config/-/react-native-config-1.5.0.tgz#ff5a78fbbc2c2a0525788e5f3c86101110651ba4"
+ integrity sha512-slecooA/0tCwhb+RuWEbwLqtKirGh9vWPRpgDfH7uPAraCciqHNH2XjS9ylW+Spn4FUrHg5KWTqUGs9BdBADHg==
+
react-native-gesture-handler@^2.9.0:
version "2.9.0"
resolved "https://registry.npmmirror.com/react-native-gesture-handler/-/react-native-gesture-handler-2.9.0.tgz#2f63812e523c646f25b9ad660fc6f75948e51241"
@@ -6987,6 +6992,11 @@ react-native-gesture-handler@^2.9.0:
lodash "^4.17.21"
prop-types "^15.7.2"
+react-native-getui@^1.1.42:
+ version "1.1.42"
+ resolved "https://registry.npmmirror.com/react-native-getui/-/react-native-getui-1.1.42.tgz#f4aa1f53e10584d4cf65bec5dd8afd58f08d0055"
+ integrity sha512-esRbDBI5G99/p7+zHEpm9J8V2oEv2L/xRMv1Voi0yxFcnhWd3i1OTodtnC+k+9lurYqu/A4MhTPL99hZcJ/ROg==
+
react-native-gradle-plugin@^0.71.14:
version "0.71.14"
resolved "https://registry.npmmirror.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.14.tgz#cc399662f04fbfcc0e352d03eae1d3efbd5f635a"