refactor(mobile): refactor to manual integrate getui

pull/90/head
moonrailgun 2 years ago
parent 3c94ac2438
commit 0aa17081ea

@ -192,6 +192,8 @@ dependencies {
}
// Push
implementation 'com.getui:gtsdk:3.2.15.0' //SDK
implementation 'com.getui:gtc:3.2.1.0' //
implementation 'com.huawei.hms:push:6.9.0.300'
}

@ -22,9 +22,27 @@
</intent-filter>
</activity>
<!-- 个推SDK配置开始 -->
<!-- 用户自定义服务继承自GTIntentService,作为SDK与APP桥梁服务,用来接收各种消息和命令回复 -->
<service
android:name="com.msgbyte.tailchat.PushIntentService"/>
<!-- 配置SDK核心服务 -->
<service
android:name="com.msgbyte.tailchat.TailchatPushService"
android:exported="true"
android:label="PushService"
android:process=":pushservice" />
<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"/>
<!-- 个推SDK配置结束 -->
</application>
<queries>
<intent>
<action android:name="com.getui.sdk.action" />
</intent>
</queries>
</manifest>

@ -0,0 +1,16 @@
package com.msgbyte.tailchat;
import android.util.Log;
public class GetuiLogger {
public static boolean ENABLE = true;
public static final String TAG = "GetuiLogger";
public static void log(String message){
if (ENABLE){
Log.d(TAG, message);
}
}
}

@ -0,0 +1,349 @@
package com.msgbyte.tailchat;
import android.content.Context;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.igexin.sdk.PushManager;
import com.igexin.sdk.Tag;
public class GetuiModule extends ReactContextBaseJavaModule {
private static final String TAG = "GetuiModule";
public static final String EVENT_RECEIVE_REMOTE_NOTIFICATION = "receiveRemoteNotification";
public static final String EVENT_TYPE_RECEIVE_CID = "cid";
public static final String EVENT_TYPE_PAYLOAD = "payload";
public static final String EVENT_TYPE_CMD = "cmd";
public static final String EVENT_TYPE_NOTIFICATION_ARRIVED = "notificationArrived";
public static final String EVENT_TYPE_NOTIFICATION_CLICKED = "notificationClicked";
private static ReactApplicationContext mRAC;
private static GetuiModule mModule;
private static Context mContext;
public GetuiModule(ReactApplicationContext reactContext) {
super(reactContext);
mRAC = reactContext;
}
@Override
public boolean canOverrideExistingModule() {
return true;
}
@Override
public String getName() {
return "GetuiModule";
}
@Override
public void initialize() {
super.initialize();
mModule = this;
}
@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
mModule = null;
}
/**
*
*/
public static void initPush(Context context) {
mContext = context;
GetuiLogger.log("initPush, mContext = " + mContext);
PushManager.getInstance().initialize(mContext, TailchatPushService.class);
PushManager.getInstance().registerPushIntentService(mContext, PushIntentService.class);
}
/**
* Android destroy
*/
@ReactMethod
public void destroy() {
// PushManager.getInstance().stopService(mContext);
}
/**
* SDK
*/
@ReactMethod
public void stop() {
// PushManager.getInstance().stopService(mContext);
}
/**
* SDK
*/
@ReactMethod
public void resume() {
PushManager.getInstance().turnOnPush(mContext);
}
/**
* SDK.
*/
@ReactMethod
public void turnOnPush() {
PushManager.getInstance().turnOnPush(mContext);
}
/**
* SDK.
*/
@ReactMethod
public void turnOffPush() {
PushManager.getInstance().turnOffPush(mContext);
}
/**
* SDKCid
*
* @return Cid
*/
@ReactMethod
public void clientId(Callback callback) {
String clientId = PushManager.getInstance().getClientid(mContext);
GetuiLogger.log("clientId = " + clientId);
callback.invoke(clientId);
}
/**
* SDK,
*
* @return 12
*/
@ReactMethod
public void status(Callback callback) {
boolean isPushTurnOn = PushManager.getInstance().isPushTurnedOn(mContext);
GetuiLogger.log("isPushTurnOn = " + isPushTurnOn);
callback.invoke(isPushTurnOn ? "1" : "2");
}
/**
* SDK
*
* @return
*/
@ReactMethod
public void version(Callback callback) {
String version = PushManager.getInstance().getVersion(mContext);
GetuiLogger.log("version = " + version);
callback.invoke(version);
}
/**
* SDK (true)
* AndroidiOS
*
* @param isEnable
*/
@ReactMethod
public void runBackgroundEnable(boolean isEnable) {
// Empty
}
/**
*
* AndroidiOSAndroidManifest.xml
* <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
* <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
*
* @param isEnable NO
* @param isVerify SDKNO
*/
@ReactMethod
public void lbsLocationEnable(boolean isEnable, boolean isVerify) {
// Empty
}
/**
*
* AndroidiOSØ
*
* @param channelId
*/
@ReactMethod
public void setChannelId(String channelId) {
// Empty
}
/**
* DeviceToken
* AndroidiOS
*
* @param deviceToken
*/
@ReactMethod
public void registerDeviceToken(String deviceToken) {
// Empty
}
/**
* :
*
* @param alias
* @param aSn , AndroidiOS
*/
@ReactMethod
public void bindAlias(String alias, String aSn) {
PushManager.getInstance().bindAlias(mContext, alias);
}
/**
*
*
* @param alias
* @param aSn , AndroidiOS
*/
@ReactMethod
public void unbindAlias(String alias, String aSn) {
PushManager.getInstance().unBindAlias(mContext, alias, false);
}
/**
* ,
*
* @param tags
*/
@ReactMethod
public void setTag(ReadableArray tags) {
if (tags == null || tags.size() == 0) {
return;
}
Tag[] tagArray = new Tag[tags.size()];
for (int i = 0; i < tags.size(); i++) {
Tag tag = new Tag();
tag.setName(tags.getString(i));
tagArray[i] = tag;
}
PushManager.getInstance().setTag(mContext, tagArray, "setTag");
}
/**
*
* AndroidiOS
*
* @param isValue
*/
@ReactMethod
public void setPushModeForOff(boolean isValue) {
// Empty
}
/**
*
* AndroidiOS
*
* @param value
*/
@ReactMethod
public void setBadge(int value) {
// Empty
}
/**
*
* AndroidiOS
*
* @param badge
*/
@ReactMethod
public void resetBadge(int badge) {
//Empty
}
/**
* SDK
* AndroidiOS
*
* @param body
* @param error messageid
*/
@ReactMethod
public void sendMessage(String body, String error) {
// Empty
}
/**
* actionid
*
* @param actionId actionidint90001-90999
* @param taskId ID
* @param msgId ID
* @return taskid messageid actionid
*/
@ReactMethod
public void sendFeedbackMessage(int actionId, String taskId, String msgId, Callback callback) {
callback.invoke(PushManager.getInstance().sendFeedbackMessage(mContext, taskId, msgId, actionId));
}
/**
*
*
* @param beginHour 0-23 h
* @param duration 0-230 h
*/
@ReactMethod
public void sendSilentTime(int beginHour, int duration, Callback callback) {
callback.invoke(PushManager.getInstance().setSilentTime(mContext, beginHour, duration));
}
/**
* Socket
*
* @param times
*/
@ReactMethod
public void setSocketTimeout(int times) {
PushManager.getInstance().setSocketTimeout(mContext, times);
}
/**
* JavaScript
*
* @param eventName
* @param type
* @param value
*/
public static void sendEvent(String eventName, String type, String key, String value) {
WritableMap param = Arguments.createMap();
param.putString("type", type);
param.putString(key, value);
sendEvent(eventName, param);
}
/**
* JavaScript
*
* @param eventName
* @param params
*/
public static void sendEvent(String eventName, @Nullable WritableMap params) {
mRAC.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
}
}

@ -9,7 +9,6 @@ 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 {

@ -0,0 +1,103 @@
package com.msgbyte.tailchat;
import android.content.Context;
import androidx.annotation.RequiresPermission;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTNotificationMessage;
import com.igexin.sdk.message.GTTransmitMessage;
/**
* GTIntentService , 线<br>
* onReceiveMessageData <br>
* onReceiveClientId cid <br>
* onReceiveOnlineState cid 线线 <br>
* onReceiveCommandResult <br>
*/
public class PushIntentService extends GTIntentService {
public PushIntentService() {
}
@Override
public void onReceiveServicePid(Context context, int pid) {
GetuiLogger.log("onReceiveServicePid = " + pid);
}
@Override
public void onReceiveClientId(Context context, String clientId) {
GetuiLogger.log("onReceiveClientId = " + clientId);
WritableMap param = Arguments.createMap();
param.putString("type", GetuiModule.EVENT_TYPE_RECEIVE_CID);
param.putString("cid", clientId);
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION, param);
}
@Override
public void onReceiveMessageData(Context context, GTTransmitMessage msg) {
String message = new String(msg.getPayload());
GetuiLogger.log("onReceiveMessageData msg = " + message);
WritableMap param = Arguments.createMap();
param.putString("type", GetuiModule.EVENT_TYPE_PAYLOAD);
param.putString("payload", message);
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION, param );
}
@Override
public void onReceiveOnlineState(Context context, boolean online) {
GetuiLogger.log("onReceiveOnlineState online = " + online);
}
@Override
public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) {
GetuiLogger.log("onReceiveCommandResult cmdMessage action = " + cmdMessage.getAction());
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION,
GetuiModule.EVENT_TYPE_CMD, "action", String.valueOf(cmdMessage.getAction()));
}
// 通知到达
@Override
public void onNotificationMessageArrived(Context context, GTNotificationMessage message) {
GetuiLogger.log("onNotificationMessageArrived -> " + "appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = "
+ message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = "
+ message.getTitle() + "\ncontent = " + message.getContent());
/*
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION,GetuiModule.EVENT_TYPE_CMD,"NotificationArrived",String.valueOf("appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = "
+ message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = "
+ message.getTitle() + "\ncontent = " + message.getContent()));
*/
WritableMap param = Arguments.createMap();
param.putString("type",GetuiModule.EVENT_TYPE_NOTIFICATION_ARRIVED);
param.putString("taskId",message.getTaskId());
param.putString("messageId",message.getMessageId());
param.putString("title",message.getTitle());
param.putString("content",message.getContent());
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION,param);
}
// 点击回调
@Override
public void onNotificationMessageClicked(Context context, GTNotificationMessage message) {
GetuiLogger.log("onNotificationMessageClicked -> " + "appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = "
+ message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = "
+ message.getTitle() + "\ncontent = " + message.getContent());
/*
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION,GetuiModule.EVENT_TYPE_CMD,"NotificatioClicked","appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = "
+ message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = "
+ message.getTitle() + "\ncontent = " + message.getContent());
*/
WritableMap param = Arguments.createMap();
param.putString("type",GetuiModule.EVENT_TYPE_NOTIFICATION_CLICKED);
param.putString("taskId",message.getTaskId());
param.putString("messageId",message.getMessageId());
param.putString("title",message.getTitle());
param.putString("content",message.getContent());
GetuiModule.sendEvent(GetuiModule.EVENT_RECEIVE_REMOTE_NOTIFICATION,param);
}
}

@ -0,0 +1,6 @@
package com.msgbyte.tailchat;
import com.igexin.sdk.PushService;
public class TailchatPushService extends PushService {
}

@ -1,6 +1,5 @@
rootProject.name = 'Tailchat'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-getui'
project(':react-native-getui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-getui/android')
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')

@ -73,11 +73,6 @@ 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)
@ -468,7 +463,6 @@ 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`)
@ -497,7 +491,6 @@ 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)
@ -553,12 +546,10 @@ SPEC REPOS:
- Flipper-RSocket
- FlipperKit
- fmt
- GTSDK
- libevent
- OpenSSL-Universal
- SocketRocket
- YogaKit
- ZXSDK
EXTERNAL SOURCES:
boost:
@ -571,8 +562,6 @@ 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:
@ -665,8 +654,6 @@ SPEC CHECKSUMS:
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
GTSDK: f28e6d575e8a1c26e331ce29b0ecac7db39679cc
GtSdkRN: d43bf94df00093d6a19a071080743cb4519bedd1
hermes-engine: 6351580c827b3b03e5f25aadcf989f582d0b0a86
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
@ -708,7 +695,6 @@ SPEC CHECKSUMS:
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: 5b0304b3dbef2b52e078052138e23a19c7dacaef
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
ZXSDK: 3ae8f7f2c5d45b4c1def43e14d930495c5f4d424
PODFILE CHECKSUM: 9aaf3e7752d79b6a889333eec3c3b53e8133916b

@ -15,7 +15,7 @@
},
"dependencies": {
"@formatjs/intl": "^2.6.9",
"@notifee/react-native": "^7.4.0",
"@notifee/react-native": "^7.6.1",
"@react-native-async-storage/async-storage": "^1.17.11",
"immer": "^9.0.19",
"lodash": "^4.17.21",
@ -26,7 +26,6 @@
"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-localize": "^2.2.6",
"react-native-reanimated": "^2.14.4",
"react-native-ui-lib": "^6.29.1",

@ -1,42 +0,0 @@
diff --git a/node_modules/react-native-getui/android/build.gradle b/node_modules/react-native-getui/android/build.gradle
index 7cb66cf..86d81cf 100644
--- a/node_modules/react-native-getui/android/build.gradle
+++ b/node_modules/react-native-getui/android/build.gradle
@@ -68,11 +68,4 @@ dependencies {
implementation 'com.getui:gtsdk:3.2.13.0' //个推SDK
implementation 'com.getui:gtc:3.1.12.0' //个推核心组件
-
- implementation 'com.getui.opt:hwp:3.1.1' // 华为
- implementation 'com.getui.opt:xmp:3.3.0' // 小米
- implementation 'com.assist-v3:oppo:3.2.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' // upsups目前支持坚果索尼海信手机
}
diff --git a/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/GetuiModule.java b/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/GetuiModule.java
index 1b1df8c..9065358 100755
--- a/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/GetuiModule.java
+++ b/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/GetuiModule.java
@@ -2,7 +2,7 @@ package com.getui.reactnativegetui;
import android.content.Context;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
diff --git a/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/PushIntentService.java b/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/PushIntentService.java
index 4f66448..ec32933 100644
--- a/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/PushIntentService.java
+++ b/node_modules/react-native-getui/android/src/main/java/com/getui/reactnativegetui/PushIntentService.java
@@ -5,7 +5,7 @@ package com.getui.reactnativegetui;
*/
import android.content.Context;
-import android.support.annotation.RequiresPermission;
+import androidx.annotation.RequiresPermission;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;

@ -1,9 +1,13 @@
import Getui from 'react-native-getui';
import { NativeModules, Platform } from 'react-native';
const GetuiModule = NativeModules.GetuiModule;
/**
* bind alias with userId
* user for server push
*/
export function bindAlias(userId: string) {
Getui.bindAlias(userId);
if (Platform.OS === 'android') {
GetuiModule.bindAlias(userId);
}
}

@ -1506,10 +1506,10 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@notifee/react-native@^7.4.0":
version "7.4.0"
resolved "https://registry.npmmirror.com/@notifee/react-native/-/react-native-7.4.0.tgz#0f20744307bf3b800f7b56eb2d0bbdd474748d09"
integrity sha512-c8pkxDQFRbw0JlUmTb07OTG/4LQHRj8MBodMLwEcO+SvqIxK8ya8zSUEzfdcdWsSVqdoym0v3zpSNroR3Quj/w==
"@notifee/react-native@^7.6.1":
version "7.6.1"
resolved "https://registry.npmmirror.com/@notifee/react-native/-/react-native-7.6.1.tgz#e215428787396ec57ea424106cc88666f7efe70d"
integrity sha512-OjhLPODh6FICYZmF9/0UZbcl2JPaPpcrWi1Cvs/OLFbPSJTIEwPZgXFrCHv/cA3wUX4YQCXreSqQGSVQgvNItQ==
"@react-native-async-storage/async-storage@^1.17.11":
version "1.17.11"
@ -7143,11 +7143,6 @@ 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