feat(mobile): integrate getui for chinese mainland notify push

pull/90/head
moonrailgun 2 years ago
parent bd56d517e8
commit 256cb43c93

@ -0,0 +1,3 @@
GETUI_APPID=
GETUI_APPKEY=
GETUI_APPSECRET=

@ -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 {

@ -10,4 +10,9 @@
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
</application>
<meta-data android:name="PUSH_APPID" android:value="@string/GETUI_APPID"/>
<meta-data android:name="PUSH_APPKEY" android:value="@string/GETUI_APPKEY"/>
<meta-data android:name="PUSH_APPSECRET" android:value="@string/GETUI_APPSECRET"/>
</manifest>

@ -21,5 +21,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="PUSH_APPID" android:value="@string/GETUI_APPID"/>
<meta-data android:name="PUSH_APPKEY" android:value="@string/GETUI_APPKEY"/>
<meta-data android:name="PUSH_APPSECRET" android:value="@string/GETUI_APPSECRET"/>
</application>
</manifest>

@ -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();

@ -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()
}
}

@ -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')

@ -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

@ -1,5 +1,13 @@
#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
#if __has_include(<RCTGetuiModule/RCTGetuiModule.h>)
#import <RCTGetuiModule/RCTGetuiModule.h>
#elif __has_include("RCTGetuiModule.h")
#import "RCTGetuiModule.h"
#elif __has_include(<GtSdkRN/RCTGetuiModule.h>)
#import <GtSdkRN/RCTGetuiModule.h>
#endif
@interface AppDelegate : RCTAppDelegate

@ -1,4 +1,5 @@
#import "AppDelegate.h"
#import "RNCConfig.h"
#import <React/RCTBundleURLProvider.h>
@ -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.

@ -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",

@ -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) => {

@ -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);
}

@ -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(() => {

@ -0,0 +1 @@
declare module 'react-native-getui';

@ -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"

Loading…
Cancel
Save