diff --git a/client/mobile/.env.example b/client/mobile/.env.example index 901591a0..f81c1184 100644 --- a/client/mobile/.env.example +++ b/client/mobile/.env.example @@ -1,3 +1,8 @@ +TAILCHAT_UPLOAD_STORE_FILE= +TAILCHAT_UPLOAD_STORE_PASSWORD= +TAILCHAT_UPLOAD_KEY_ALIAS= +TAILCHAT_UPLOAD_KEY_PASSWORD= + GETUI_APPID= GETUI_APPKEY= GETUI_APPSECRET= diff --git a/client/mobile/android/app/build.gradle b/client/mobile/android/app/build.gradle index 8b1d6e23..1258a16b 100644 --- a/client/mobile/android/app/build.gradle +++ b/client/mobile/android/app/build.gradle @@ -132,10 +132,17 @@ android { } signingConfigs { debug { - storeFile file('debug.keystore') - storePassword 'android' - keyAlias 'androiddebugkey' - keyPassword 'android' + if (project.env.get('TAILCHAT_UPLOAD_STORE_FILE')) { + storeFile file(project.env.get('TAILCHAT_UPLOAD_STORE_FILE')) + storePassword project.env.get('TAILCHAT_UPLOAD_STORE_PASSWORD') + keyAlias project.env.get('TAILCHAT_UPLOAD_KEY_ALIAS') + keyPassword project.env.get('TAILCHAT_UPLOAD_KEY_PASSWORD') + } else { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } } } buildTypes { @@ -194,6 +201,16 @@ dependencies { // Push implementation 'com.getui:gtsdk:3.2.15.0' //个推SDK implementation 'com.getui:gtc:3.2.1.0' //个推核心组件 + + // 根据所需厂商选择集成 + implementation 'com.getui.opt:hwp:3.1.1' // 华为 + // implementation 'com.getui.opt:xmp:3.3.0' // 小米 + // implementation 'com.assist-v3:oppo:3.3.0' // oppo + // implementation 'com.assist-v3:vivo:3.1.1' // vivo + // implementation 'com.getui.opt:mzp:3.2.2' // 魅族 + // implementation 'com.getui.opt:ups:3.0.3' // ups,ups目前支持坚果,索尼,海信手机 + // implementation 'com.getui.opt:honor:3.3.0' // 荣耀 + implementation 'com.huawei.hms:push:6.9.0.300' } diff --git a/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/GetuiPackage.java b/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/GetuiPackage.java new file mode 100644 index 00000000..3449541a --- /dev/null +++ b/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/GetuiPackage.java @@ -0,0 +1,37 @@ +package com.msgbyte.tailchat; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.JavaScriptModule; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class GetuiPackage implements ReactPackage { + public GetuiPackage(boolean logEnable) { + GetuiLogger.ENABLE = logEnable; + } + + public GetuiPackage(){ + GetuiLogger.ENABLE = true; + } + + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Arrays.asList(new NativeModule[]{ + new GetuiModule(reactContext) + }); + } + + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} diff --git a/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/MainApplication.java b/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/MainApplication.java index 32bdfceb..59295ec9 100644 --- a/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/MainApplication.java +++ b/client/mobile/android/app/src/main/java/com/msgbyte/tailchat/MainApplication.java @@ -24,7 +24,7 @@ public class MainApplication extends Application implements ReactApplication { @SuppressWarnings("UnnecessaryLocalVariable") List 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 GetuiPackage()); return packages; } diff --git a/client/mobile/src/lib/notifications/getui.ts b/client/mobile/src/lib/notifications/getui.ts index 29ce8626..f95d9e06 100644 --- a/client/mobile/src/lib/notifications/getui.ts +++ b/client/mobile/src/lib/notifications/getui.ts @@ -1,5 +1,4 @@ import { NativeModules, Platform } from 'react-native'; - const GetuiModule = NativeModules.GetuiModule; /** @@ -7,7 +6,18 @@ const GetuiModule = NativeModules.GetuiModule; * user for server push */ export function bindAlias(userId: string) { + getClientId().then((cid) => { + console.log('getui cid:', cid); + }); if (Platform.OS === 'android') { - GetuiModule.bindAlias(userId); + GetuiModule.bindAlias(userId, '0'); } } + +export function getClientId() { + return new Promise((resolve) => { + GetuiModule.clientId((param: string) => { + resolve(param); + }); + }); +} diff --git a/client/mobile/src/lib/notifications/index.ts b/client/mobile/src/lib/notifications/index.ts index 6ec4f823..c866808a 100644 --- a/client/mobile/src/lib/notifications/index.ts +++ b/client/mobile/src/lib/notifications/index.ts @@ -55,9 +55,10 @@ export async function initNotificationEnv(options: NotificationOptions) { bindAlias(options.userId); // 厂商渠道还没有ready, 推送需要依赖前台服务保活 - await initForegroundService(options); + // 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 deleted file mode 100644 index cf021fe5..00000000 --- a/client/mobile/types/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'react-native-getui';