@onekeyfe/react-native-jpush 0.0.0-stage → 6.7.0-alpha.436
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/ReactNativeJpush.podspec +66 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +143 -0
- package/android/fcm/build.gradle +29 -0
- package/android/fcm/consumer-rules.pro +2 -0
- package/android/fcm/src/main/AndroidManifest.xml +16 -0
- package/android/fcm/src/main/java/com/onekey/jpush/fcm/FcmMessagingService.java +72 -0
- package/android/fcm/src/main/java/com/onekey/jpush/fcm/FcmPushManager.java +69 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +143 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/cn/android/service/JTransitActivity.java +19 -0
- package/android/src/main/java/cn/jiguang/android/BuildConfig.java +10 -0
- package/android/src/main/java/cn/jiguang/android/IDataShare.java +190 -0
- package/android/src/main/java/cn/jiguang/api/BaseLogger.java +82 -0
- package/android/src/main/java/cn/jiguang/api/JAction.java +22 -0
- package/android/src/main/java/cn/jiguang/api/JActionExtra.java +21 -0
- package/android/src/main/java/cn/jiguang/api/JAnalyticsAction.java +11 -0
- package/android/src/main/java/cn/jiguang/api/JCoreInterface.java +228 -0
- package/android/src/main/java/cn/jiguang/api/JCoreManager.java +156 -0
- package/android/src/main/java/cn/jiguang/api/JDispatchAction.java +66 -0
- package/android/src/main/java/cn/jiguang/api/MultiSpHelper.java +114 -0
- package/android/src/main/java/cn/jiguang/api/ReportCallBack.java +9 -0
- package/android/src/main/java/cn/jiguang/api/SdkType.java +13 -0
- package/android/src/main/java/cn/jiguang/api/utils/JCollectionAuth.java +23 -0
- package/android/src/main/java/cn/jiguang/core/JCoreCrypto.java +545 -0
- package/android/src/main/java/cn/jiguang/core/JCoreStorage.java +737 -0
- package/android/src/main/java/cn/jiguang/core/JCoreTcpEngine.java +1395 -0
- package/android/src/main/java/cn/jiguang/core/JCoreWireCodec.java +1716 -0
- package/android/src/main/java/cn/jiguang/internal/ActionManager.java +63 -0
- package/android/src/main/java/cn/jiguang/internal/JConstants.java +61 -0
- package/android/src/main/java/cn/jiguang/internal/JCoreHelperAction.java +12 -0
- package/android/src/main/java/cn/jiguang/internal/JCoreInternalHelper.java +102 -0
- package/android/src/main/java/cn/jiguang/net/DefaultHostVerifier.java +40 -0
- package/android/src/main/java/cn/jiguang/net/HttpRequest.java +78 -0
- package/android/src/main/java/cn/jiguang/net/HttpResponse.java +48 -0
- package/android/src/main/java/cn/jiguang/net/HttpUtils.java +106 -0
- package/android/src/main/java/cn/jiguang/plugins/core/JCoreModule.java +91 -0
- package/android/src/main/java/cn/jiguang/plugins/core/JCorePackage.java +27 -0
- package/android/src/main/java/cn/jiguang/plugins/push/JPushModule.java +773 -0
- package/android/src/main/java/cn/jiguang/plugins/push/JPushPackage.java +25 -0
- package/android/src/main/java/cn/jiguang/plugins/push/common/JConstants.java +88 -0
- package/android/src/main/java/cn/jiguang/plugins/push/common/JLogger.java +122 -0
- package/android/src/main/java/cn/jiguang/plugins/push/helper/JPushHelper.java +710 -0
- package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushBroadcastReceiver.java +37 -0
- package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushModuleReceiver.java +264 -0
- package/android/src/main/java/cn/jiguang/plugins/service/JCoreModuleService.java +7 -0
- package/android/src/main/java/cn/jpush/android/api/BasicPushNotificationBuilder.java +83 -0
- package/android/src/main/java/cn/jpush/android/api/CallBackParams.java +50 -0
- package/android/src/main/java/cn/jpush/android/api/CmdMessage.java +33 -0
- package/android/src/main/java/cn/jpush/android/api/CustomMessage.java +28 -0
- package/android/src/main/java/cn/jpush/android/api/CustomPushNotificationBuilder.java +81 -0
- package/android/src/main/java/cn/jpush/android/api/DefaultPushNotificationBuilder.java +90 -0
- package/android/src/main/java/cn/jpush/android/api/InAppSlotParams.java +65 -0
- package/android/src/main/java/cn/jpush/android/api/InstrumentedActivity.java +17 -0
- package/android/src/main/java/cn/jpush/android/api/InstrumentedListActivity.java +17 -0
- package/android/src/main/java/cn/jpush/android/api/JPushInterface.java +490 -0
- package/android/src/main/java/cn/jpush/android/api/JPushMessage.java +121 -0
- package/android/src/main/java/cn/jpush/android/api/JThirdPlatFormInterface.java +247 -0
- package/android/src/main/java/cn/jpush/android/api/MultiActionsNotificationBuilder.java +72 -0
- package/android/src/main/java/cn/jpush/android/api/NotificationCustomButton.java +50 -0
- package/android/src/main/java/cn/jpush/android/api/NotificationMessage.java +67 -0
- package/android/src/main/java/cn/jpush/android/api/PushNotificationBuilder.java +13 -0
- package/android/src/main/java/cn/jpush/android/api/TagAliasCallback.java +8 -0
- package/android/src/main/java/cn/jpush/android/data/JPushCollectControl.java +96 -0
- package/android/src/main/java/cn/jpush/android/data/JPushConfig.java +79 -0
- package/android/src/main/java/cn/jpush/android/data/JPushConfigEx.java +41 -0
- package/android/src/main/java/cn/jpush/android/data/JPushLocalNotification.java +155 -0
- package/android/src/main/java/cn/jpush/android/helper/JCoreHelper.java +70 -0
- package/android/src/main/java/cn/jpush/android/helper/Logger.java +82 -0
- package/android/src/main/java/cn/jpush/android/local/ActionHelper.java +1277 -0
- package/android/src/main/java/cn/jpush/android/local/ActivityLifeCallBack.java +47 -0
- package/android/src/main/java/cn/jpush/android/local/JPushAction.java +67 -0
- package/android/src/main/java/cn/jpush/android/local/JPushConstants.java +34 -0
- package/android/src/main/java/cn/jpush/android/local/JPushResponse.java +26 -0
- package/android/src/main/java/cn/jpush/android/local/ProxyActivityAction.java +34 -0
- package/android/src/main/java/cn/jpush/android/service/AlarmReceiver.java +15 -0
- package/android/src/main/java/cn/jpush/android/service/BActivity.java +19 -0
- package/android/src/main/java/cn/jpush/android/service/DActivity.java +19 -0
- package/android/src/main/java/cn/jpush/android/service/DaemonService.java +17 -0
- package/android/src/main/java/cn/jpush/android/service/DataProvider.java +136 -0
- package/android/src/main/java/cn/jpush/android/service/DataShare.java +129 -0
- package/android/src/main/java/cn/jpush/android/service/DownloadProvider.java +139 -0
- package/android/src/main/java/cn/jpush/android/service/InitProvider.java +48 -0
- package/android/src/main/java/cn/jpush/android/service/JCommonService.java +79 -0
- package/android/src/main/java/cn/jpush/android/service/JNotifyActivity.java +28 -0
- package/android/src/main/java/cn/jpush/android/service/JPushMessageReceiver.java +94 -0
- package/android/src/main/java/cn/jpush/android/service/PushReceiver.java +26 -0
- package/android/src/main/java/cn/jpush/android/service/PushService.java +28 -0
- package/android/src/main/java/cn/jpush/android/service/SchedulerReceiver.java +17 -0
- package/android/src/main/java/cn/jpush/android/service/TagAliasReceiver.java +11 -0
- package/android/src/main/java/cn/jpush/android/service/WakedResultReceiver.java +24 -0
- package/android/src/main/java/cn/jpush/android/ui/FullScreenView.java +11 -0
- package/android/src/main/java/cn/jpush/android/ui/PopWinActivity.java +16 -0
- package/android/src/main/java/cn/jpush/android/ui/PushActivity.java +27 -0
- package/android/src/main/java/cn/jpush/android/ui/RoundedImageView.java +63 -0
- package/android/src/main/java/cn/jpush/android/ui/ShadowViewCard.java +56 -0
- package/android/src/main/java/cn/jpush/android/ups/ICallbackResult.java +5 -0
- package/android/src/main/java/cn/jpush/android/ups/JPushUPSManager.java +37 -0
- package/android/src/main/java/cn/jpush/android/ups/TokenResult.java +47 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSRegisterCallBack.java +4 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSTurnCallBack.java +4 -0
- package/android/src/main/java/cn/jpush/android/ups/UPSUnRegisterCallBack.java +4 -0
- package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpush.kt +455 -0
- package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushPackage.kt +50 -0
- package/android/src/main/res/values/jpush_string.xml +7 -0
- package/android/src/main/res/values/jpush_style.xml +22 -0
- package/android/src/test/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushProtocolTest.java +1016 -0
- package/ios/ReactNativeJpush.swift +522 -0
- package/ios/bridge/RCTJCoreModule.h +5 -0
- package/ios/bridge/RCTJCoreModule.m +31 -0
- package/ios/bridge/RCTJPushEventQueue.h +14 -0
- package/ios/bridge/RCTJPushEventQueue.m +23 -0
- package/ios/bridge/RCTJPushModule.h +37 -0
- package/ios/bridge/RCTJPushModule.m +1165 -0
- package/ios/include/JCOREService.h +3 -0
- package/ios/include/JGCOREAPI.h +14 -0
- package/ios/include/JGInforCollectionAuth.h +17 -0
- package/ios/include/JGInforCollectionAuthItems.h +2 -0
- package/ios/include/JGPushNotificationTrigger.h +2 -0
- package/ios/include/JPUSHService.h +359 -0
- package/ios/jcore/JCOREConfiguration.h +141 -0
- package/ios/jcore/JCOREConfiguration.m +703 -0
- package/ios/jcore/JCORECrypto.h +73 -0
- package/ios/jcore/JCORECrypto.m +649 -0
- package/ios/jcore/JCORESisResolver.h +56 -0
- package/ios/jcore/JCORESisResolver.m +525 -0
- package/ios/jcore/JCORETcpSession.h +42 -0
- package/ios/jcore/JCORETcpSession.m +956 -0
- package/ios/jcore/JCOREWireProtocol.h +274 -0
- package/ios/jcore/JCOREWireProtocol.m +1453 -0
- package/ios/jpush/JPUSHModels.m +214 -0
- package/ios/jpush/JPUSHNotificationManager.h +34 -0
- package/ios/jpush/JPUSHNotificationManager.m +360 -0
- package/ios/jpush/JPUSHService.m +794 -0
- package/ios/tests/ReactNativeJpushTests.m +148 -0
- package/lib/module/ReactNativeJpush.nitro.js +4 -0
- package/lib/module/ReactNativeJpush.nitro.js.map +1 -0
- package/lib/module/index.js +801 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativeJpush.nitro.d.ts +60 -0
- package/lib/typescript/src/ReactNativeJpush.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +235 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.cpp +310 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.hpp +115 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_bool.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_std__string_std__string.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/HybridReactNativeJpushSpec.kt +274 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/reactnativejpushOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativejpush+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativejpush+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativejpushOnLoad.cpp +58 -0
- package/nitrogen/generated/android/reactnativejpushOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/ReactNativeJpush+autolinking.rb +62 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.hpp +147 -0
- package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Umbrella.hpp +46 -0
- package/nitrogen/generated/ios/ReactNativeJpushAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeJpushAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.hpp +402 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec.swift +107 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec_cxx.swift +723 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.cpp +73 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.hpp +116 -0
- package/package.json +174 -4
- package/src/ReactNativeJpush.nitro.ts +93 -0
- package/src/index.tsx +1090 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package cn.jiguang.plugins.push.receiver;
|
|
2
|
+
|
|
3
|
+
import android.content.BroadcastReceiver;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
6
|
+
import android.os.Bundle;
|
|
7
|
+
|
|
8
|
+
import cn.jiguang.plugins.push.common.JLogger;
|
|
9
|
+
import cn.jiguang.plugins.push.helper.JPushHelper;
|
|
10
|
+
import cn.jpush.android.api.JPushInterface;
|
|
11
|
+
|
|
12
|
+
public class JPushBroadcastReceiver extends BroadcastReceiver {
|
|
13
|
+
|
|
14
|
+
public static Bundle NOTIFICATION_BUNDLE;
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public void onReceive(Context context, Intent data) {
|
|
18
|
+
if (data == null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (data.getBooleanExtra("jpush_already_dispatched", false)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(data.getAction())) {
|
|
25
|
+
JLogger.d("JPushBroadcastReceiver ACTION_NOTIFICATION_OPENED");
|
|
26
|
+
try {
|
|
27
|
+
NOTIFICATION_BUNDLE = data.getExtras();
|
|
28
|
+
if (context != null) {
|
|
29
|
+
JPushHelper.launchApp(context);
|
|
30
|
+
}
|
|
31
|
+
} catch (Throwable throwable) {
|
|
32
|
+
JLogger.e("JPushBroadcastReceiver ACTION_NOTIFICATION_OPENED error:" + throwable.getMessage());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
package cn.jiguang.plugins.push.receiver;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import java.util.HashMap;
|
|
6
|
+
import java.util.Map;
|
|
7
|
+
|
|
8
|
+
import cn.jiguang.plugins.push.JPushModule;
|
|
9
|
+
import cn.jiguang.plugins.push.common.JLogger;
|
|
10
|
+
import cn.jiguang.plugins.push.common.JConstants;
|
|
11
|
+
import cn.jiguang.plugins.push.helper.JPushHelper;
|
|
12
|
+
import cn.jpush.android.api.CmdMessage;
|
|
13
|
+
import cn.jpush.android.api.CustomMessage;
|
|
14
|
+
import cn.jpush.android.api.JPushMessage;
|
|
15
|
+
import cn.jpush.android.api.NotificationMessage;
|
|
16
|
+
import cn.jpush.android.service.JPushMessageReceiver;
|
|
17
|
+
import cn.jpush.android.api.NotificationCustomButton;
|
|
18
|
+
|
|
19
|
+
public class JPushModuleReceiver extends JPushMessageReceiver {
|
|
20
|
+
|
|
21
|
+
private static String safeId(String value) {
|
|
22
|
+
return value != null ? value : "";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public void onMessage(Context context, CustomMessage customMessage) {
|
|
27
|
+
if (customMessage != null) {
|
|
28
|
+
JLogger.i(
|
|
29
|
+
"onMessage type=customMessage msgId="
|
|
30
|
+
+ safeId(customMessage.messageId)
|
|
31
|
+
+ " platform="
|
|
32
|
+
+ customMessage.platform
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
Map<String, Object> map = JPushHelper.convertCustomMessageToMapObject(customMessage);
|
|
36
|
+
JPushHelper.sendEventMap(JConstants.CUSTOM_MESSAGE_EVENT, map);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
|
|
41
|
+
if (notificationMessage == null) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
String eventType =
|
|
45
|
+
notificationMessage.notificationType == 1 ? "localNotification" : JConstants.NOTIFICATION_ARRIVED;
|
|
46
|
+
JLogger.i(
|
|
47
|
+
"onNotifyMessageArrived type="
|
|
48
|
+
+ eventType
|
|
49
|
+
+ " notificationType="
|
|
50
|
+
+ notificationMessage.notificationType
|
|
51
|
+
+ " msgId="
|
|
52
|
+
+ safeId(notificationMessage.msgId)
|
|
53
|
+
+ " notificationId="
|
|
54
|
+
+ notificationMessage.notificationId
|
|
55
|
+
);
|
|
56
|
+
Map<String, Object> map = JPushHelper.convertNotificationToMapObject(JConstants.NOTIFICATION_ARRIVED, notificationMessage);
|
|
57
|
+
if (notificationMessage.notificationType != 1) {
|
|
58
|
+
JPushHelper.sendEventMap(JConstants.NOTIFICATION_EVENT, map);
|
|
59
|
+
} else {
|
|
60
|
+
JPushHelper.sendEventMap(JConstants.LOCAL_NOTIFICATION_EVENT, map);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@Override
|
|
64
|
+
public void onPropertyOperatorResult(Context context, JPushMessage jPushMessage) {
|
|
65
|
+
if (jPushMessage != null) {
|
|
66
|
+
JLogger.i(
|
|
67
|
+
"onPropertyOperatorResult seq="
|
|
68
|
+
+ jPushMessage.getSequence()
|
|
69
|
+
+ " code="
|
|
70
|
+
+ jPushMessage.getErrorCode()
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
Map<String, Object> map = JPushHelper.convertJPushMessageToMapObject(4, jPushMessage);
|
|
74
|
+
JPushHelper.sendEventMap(JConstants.TAG_ALIAS_EVENT, map);
|
|
75
|
+
}
|
|
76
|
+
@Override
|
|
77
|
+
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
|
|
78
|
+
JPushBroadcastReceiver.NOTIFICATION_BUNDLE = null;
|
|
79
|
+
if (notificationMessage != null) {
|
|
80
|
+
JLogger.i(
|
|
81
|
+
"onNotifyMessageOpened type="
|
|
82
|
+
+ JConstants.NOTIFICATION_OPENED
|
|
83
|
+
+ " notificationType="
|
|
84
|
+
+ notificationMessage.notificationType
|
|
85
|
+
+ " msgId="
|
|
86
|
+
+ safeId(notificationMessage.msgId)
|
|
87
|
+
+ " notificationId="
|
|
88
|
+
+ notificationMessage.notificationId
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (!JPushModule.isAppForeground) {
|
|
92
|
+
JPushHelper.launchApp(context);
|
|
93
|
+
}
|
|
94
|
+
Map<String, Object> map = JPushHelper.convertNotificationToMapObject(JConstants.NOTIFICATION_OPENED, notificationMessage);
|
|
95
|
+
if (notificationMessage != null && notificationMessage.notificationType == 1) {
|
|
96
|
+
JPushHelper.sendEventMap(JConstants.LOCAL_NOTIFICATION_EVENT, map);
|
|
97
|
+
} else {
|
|
98
|
+
JPushHelper.sendEventMap(JConstants.NOTIFICATION_EVENT, map);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
@Override
|
|
102
|
+
public void onInAppMessageShow(Context context, NotificationMessage notificationMessage) {
|
|
103
|
+
if (notificationMessage != null) {
|
|
104
|
+
JLogger.i(
|
|
105
|
+
"onInAppMessageShow type="
|
|
106
|
+
+ JConstants.IN_APP_MESSAGE_SHOW
|
|
107
|
+
+ " notificationType="
|
|
108
|
+
+ notificationMessage.notificationType
|
|
109
|
+
+ " msgId="
|
|
110
|
+
+ safeId(notificationMessage.msgId)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (!JPushModule.isAppForeground) {
|
|
114
|
+
JPushHelper.launchApp(context);
|
|
115
|
+
}
|
|
116
|
+
Map<String, Object> map = JPushHelper.convertInAppMessageToMapObject(JConstants.IN_APP_MESSAGE_SHOW, notificationMessage);
|
|
117
|
+
JPushHelper.sendEventMap(JConstants.INAPP_MESSAGE_EVENT, map);
|
|
118
|
+
}
|
|
119
|
+
@Override
|
|
120
|
+
public void onInAppMessageClick(Context context, NotificationMessage notificationMessage) {
|
|
121
|
+
if (notificationMessage != null) {
|
|
122
|
+
JLogger.i(
|
|
123
|
+
"onInAppMessageClick type="
|
|
124
|
+
+ JConstants.IN_APP_MESSAGE_CLICK
|
|
125
|
+
+ " notificationType="
|
|
126
|
+
+ notificationMessage.notificationType
|
|
127
|
+
+ " msgId="
|
|
128
|
+
+ safeId(notificationMessage.msgId)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (!JPushModule.isAppForeground) {
|
|
132
|
+
JPushHelper.launchApp(context);
|
|
133
|
+
}
|
|
134
|
+
Map<String, Object> map = JPushHelper.convertInAppMessageToMapObject(JConstants.IN_APP_MESSAGE_CLICK, notificationMessage);
|
|
135
|
+
JPushHelper.sendEventMap(JConstants.INAPP_MESSAGE_EVENT, map);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Override
|
|
139
|
+
public void onNotifyMessageDismiss(Context context, NotificationMessage notificationMessage) {
|
|
140
|
+
if (notificationMessage != null) {
|
|
141
|
+
JLogger.i(
|
|
142
|
+
"onNotifyMessageDismiss type="
|
|
143
|
+
+ JConstants.NOTIFICATION_DISMISSED
|
|
144
|
+
+ " notificationType="
|
|
145
|
+
+ notificationMessage.notificationType
|
|
146
|
+
+ " msgId="
|
|
147
|
+
+ safeId(notificationMessage.msgId)
|
|
148
|
+
+ " notificationId="
|
|
149
|
+
+ notificationMessage.notificationId
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
Map<String, Object> map = JPushHelper.convertNotificationToMapObject(JConstants.NOTIFICATION_DISMISSED, notificationMessage);
|
|
153
|
+
if (notificationMessage != null && notificationMessage.notificationType == 1) {
|
|
154
|
+
JPushHelper.sendEventMap(JConstants.LOCAL_NOTIFICATION_EVENT, map);
|
|
155
|
+
} else {
|
|
156
|
+
JPushHelper.sendEventMap(JConstants.NOTIFICATION_EVENT, map);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@Override
|
|
161
|
+
public void onNotifyButtonClick(Context context, NotificationCustomButton notificationCustomButton) {
|
|
162
|
+
if (notificationCustomButton != null) {
|
|
163
|
+
JLogger.i(
|
|
164
|
+
"onNotifyButtonClick msgId="
|
|
165
|
+
+ safeId(notificationCustomButton.a)
|
|
166
|
+
+ " platform="
|
|
167
|
+
+ notificationCustomButton.b
|
|
168
|
+
+ " actionType="
|
|
169
|
+
+ notificationCustomButton.d
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
Map<String, Object> map = JPushHelper.convertNotificationCustomButtonToMapObject(notificationCustomButton);
|
|
173
|
+
JPushHelper.sendEventMap(JConstants.NOTIFY_BUTTON_CLICK_EVENT, map);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@Override
|
|
177
|
+
public void onRegister(Context context, String registrationId) {
|
|
178
|
+
JLogger.i("onRegister registrationId=" + safeId(registrationId));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@Override
|
|
182
|
+
public void onConnected(Context context, boolean state) {
|
|
183
|
+
JLogger.i("onConnected state=" + state);
|
|
184
|
+
Map<String, Object> map = new HashMap<String, Object>();
|
|
185
|
+
map.put(JConstants.CONNECT_ENABLE, Boolean.valueOf(state));
|
|
186
|
+
JPushHelper.sendEventMap(JConstants.CONNECT_EVENT, map);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Override
|
|
190
|
+
public void onCommandResult(Context context, CmdMessage message) {
|
|
191
|
+
if (message == null) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
JLogger.i("onCommandResult cmd=" + message.cmd + " errorCode=" + message.errorCode);
|
|
195
|
+
Map<String, Object> map = new HashMap<String, Object>();
|
|
196
|
+
map.put(JConstants.COMMAND, Integer.valueOf(message.cmd));
|
|
197
|
+
map.put(JConstants.COMMAND_EXTRA, message.extra != null ? message.extra.toString() : "");
|
|
198
|
+
map.put(JConstants.COMMAND_MESSAGE, message.msg != null ? message.msg : "");
|
|
199
|
+
map.put(JConstants.COMMAND_RESULT, Integer.valueOf(message.errorCode));
|
|
200
|
+
JPushHelper.sendEventMap(JConstants.COMMAND_EVENT, map);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Override
|
|
204
|
+
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
|
205
|
+
if (jPushMessage != null) {
|
|
206
|
+
JLogger.i(
|
|
207
|
+
"onTagOperatorResult seq="
|
|
208
|
+
+ jPushMessage.getSequence()
|
|
209
|
+
+ " code="
|
|
210
|
+
+ jPushMessage.getErrorCode()
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
Map<String, Object> map = JPushHelper.convertJPushMessageToMapObject(1, jPushMessage);
|
|
214
|
+
JPushHelper.sendEventMap(JConstants.TAG_ALIAS_EVENT, map);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@Override
|
|
218
|
+
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
|
219
|
+
if (jPushMessage != null) {
|
|
220
|
+
JLogger.i(
|
|
221
|
+
"onCheckTagOperatorResult seq="
|
|
222
|
+
+ jPushMessage.getSequence()
|
|
223
|
+
+ " code="
|
|
224
|
+
+ jPushMessage.getErrorCode()
|
|
225
|
+
+ " tagEnable="
|
|
226
|
+
+ jPushMessage.getTagCheckStateResult()
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
Map<String, Object> map = JPushHelper.convertJPushMessageToMapObject(2, jPushMessage);
|
|
230
|
+
JPushHelper.sendEventMap(JConstants.TAG_ALIAS_EVENT, map);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@Override
|
|
234
|
+
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
|
235
|
+
if (jPushMessage != null) {
|
|
236
|
+
JLogger.i(
|
|
237
|
+
"onAliasOperatorResult seq="
|
|
238
|
+
+ jPushMessage.getSequence()
|
|
239
|
+
+ " code="
|
|
240
|
+
+ jPushMessage.getErrorCode()
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
Map<String, Object> map = JPushHelper.convertJPushMessageToMapObject(3, jPushMessage);
|
|
244
|
+
JPushHelper.sendEventMap(JConstants.TAG_ALIAS_EVENT, map);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Override
|
|
248
|
+
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
|
249
|
+
if (jPushMessage == null) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
JLogger.i(
|
|
253
|
+
"onMobileNumberOperatorResult seq="
|
|
254
|
+
+ jPushMessage.getSequence()
|
|
255
|
+
+ " code="
|
|
256
|
+
+ jPushMessage.getErrorCode()
|
|
257
|
+
);
|
|
258
|
+
Map<String, Object> map = new HashMap<String, Object>();
|
|
259
|
+
map.put(JConstants.CODE, Integer.valueOf(jPushMessage.getErrorCode()));
|
|
260
|
+
map.put(JConstants.SEQUENCE, Integer.valueOf(jPushMessage.getSequence()));
|
|
261
|
+
JPushHelper.sendEventMap(JConstants.MOBILE_NUMBER_EVENT, map);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import android.app.Notification;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.pm.ApplicationInfo;
|
|
6
|
+
|
|
7
|
+
public class BasicPushNotificationBuilder extends DefaultPushNotificationBuilder {
|
|
8
|
+
public int notificationDefaults = -2;
|
|
9
|
+
public int notificationFlags = 16;
|
|
10
|
+
public int statusBarDrawable = 0;
|
|
11
|
+
public String developerArg0 = "developerArg0";
|
|
12
|
+
protected Context builderContext;
|
|
13
|
+
|
|
14
|
+
public BasicPushNotificationBuilder(Context context) {
|
|
15
|
+
if (context == null) {
|
|
16
|
+
throw new IllegalArgumentException("NULL context");
|
|
17
|
+
}
|
|
18
|
+
this.builderContext = context;
|
|
19
|
+
this.context = context;
|
|
20
|
+
try {
|
|
21
|
+
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
|
|
22
|
+
if (appInfo != null) {
|
|
23
|
+
this.statusBarDrawable = appInfo.icon;
|
|
24
|
+
}
|
|
25
|
+
} catch (Throwable ignored) {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public String getDeveloperArg0() {
|
|
31
|
+
return this.developerArg0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
Notification getNotification(Notification.Builder builder) {
|
|
36
|
+
if (this.notificationDefaults != -2) {
|
|
37
|
+
builder.setDefaults(this.notificationDefaults);
|
|
38
|
+
}
|
|
39
|
+
if (this.statusBarDrawable != 0) {
|
|
40
|
+
builder.setSmallIcon(this.statusBarDrawable);
|
|
41
|
+
}
|
|
42
|
+
Notification notification = builder.build();
|
|
43
|
+
notification.flags = 1 | this.notificationFlags;
|
|
44
|
+
return notification;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
void resetNotificationParams(Notification notification) {
|
|
49
|
+
notification.defaults = this.notificationDefaults;
|
|
50
|
+
notification.flags = this.notificationFlags;
|
|
51
|
+
notification.icon = this.statusBarDrawable;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
public String toString() {
|
|
56
|
+
return "basic_____" + serializeFields();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
String serializeFields() {
|
|
60
|
+
return this.notificationDefaults + "_____" + this.notificationFlags + "_____" + this.statusBarDrawable + "_____" + this.developerArg0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void parseFields(String[] parts) {
|
|
64
|
+
if (parts.length >= 4) {
|
|
65
|
+
this.notificationDefaults = Integer.parseInt(parts[1]);
|
|
66
|
+
this.notificationFlags = Integer.parseInt(parts[2]);
|
|
67
|
+
this.statusBarDrawable = Integer.parseInt(parts[3]);
|
|
68
|
+
}
|
|
69
|
+
if (parts.length >= 5) {
|
|
70
|
+
this.developerArg0 = parts[4];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public static PushNotificationBuilder parseFromPreference(Context context, String serialized) {
|
|
75
|
+
String[] parts = serialized != null ? serialized.split("_____") : new String[0];
|
|
76
|
+
String type = parts.length > 0 ? parts[0] : "basic";
|
|
77
|
+
BasicPushNotificationBuilder builder = "custom".equals(type)
|
|
78
|
+
? new CustomPushNotificationBuilder(context)
|
|
79
|
+
: new BasicPushNotificationBuilder(context);
|
|
80
|
+
builder.parseFields(parts);
|
|
81
|
+
return builder;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import java.io.Serializable;
|
|
4
|
+
import java.util.Map;
|
|
5
|
+
import java.util.Set;
|
|
6
|
+
|
|
7
|
+
public class CallBackParams implements Serializable {
|
|
8
|
+
private static final long serialVersionUID = 1L;
|
|
9
|
+
public String alias;
|
|
10
|
+
public Set<String> tags;
|
|
11
|
+
public Map<String, Object> pros;
|
|
12
|
+
public TagAliasCallback tagAliasCallBack;
|
|
13
|
+
public long sendTime;
|
|
14
|
+
public int protoType = 0;
|
|
15
|
+
public int action = 0;
|
|
16
|
+
public int sequence;
|
|
17
|
+
|
|
18
|
+
public CallBackParams(String alias, Set<String> tags, TagAliasCallback callback, long sendTime, int protoType, int action) {
|
|
19
|
+
this.alias = alias;
|
|
20
|
+
this.tags = tags;
|
|
21
|
+
this.tagAliasCallBack = callback;
|
|
22
|
+
this.sendTime = sendTime;
|
|
23
|
+
this.protoType = protoType;
|
|
24
|
+
this.action = action;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public CallBackParams(int sequence, String alias, long sendTime, int protoType, int action) {
|
|
28
|
+
this.sequence = sequence;
|
|
29
|
+
this.alias = alias;
|
|
30
|
+
this.sendTime = sendTime;
|
|
31
|
+
this.protoType = protoType;
|
|
32
|
+
this.action = action;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public CallBackParams(int sequence, Set<String> tags, long sendTime, int protoType, int action) {
|
|
36
|
+
this.sequence = sequence;
|
|
37
|
+
this.tags = tags;
|
|
38
|
+
this.sendTime = sendTime;
|
|
39
|
+
this.protoType = protoType;
|
|
40
|
+
this.action = action;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public CallBackParams(int sequence, Map<String, Object> pros, long sendTime, int protoType, int action) {
|
|
44
|
+
this.sequence = sequence;
|
|
45
|
+
this.pros = pros;
|
|
46
|
+
this.sendTime = sendTime;
|
|
47
|
+
this.protoType = protoType;
|
|
48
|
+
this.action = action;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import android.os.Bundle;
|
|
4
|
+
|
|
5
|
+
public class CmdMessage {
|
|
6
|
+
public int cmd;
|
|
7
|
+
public int errorCode;
|
|
8
|
+
public String msg;
|
|
9
|
+
public Bundle extra;
|
|
10
|
+
|
|
11
|
+
public CmdMessage(int cmd, int errorCode) {
|
|
12
|
+
this.cmd = cmd;
|
|
13
|
+
this.errorCode = errorCode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public CmdMessage(int cmd, int errorCode, String msg) {
|
|
17
|
+
this.cmd = cmd;
|
|
18
|
+
this.errorCode = errorCode;
|
|
19
|
+
this.msg = msg;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public CmdMessage(int cmd, int errorCode, String msg, Bundle extra) {
|
|
23
|
+
this.cmd = cmd;
|
|
24
|
+
this.errorCode = errorCode;
|
|
25
|
+
this.msg = msg;
|
|
26
|
+
this.extra = extra;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public String toString() {
|
|
31
|
+
return "CmdMessage{cmd=" + cmd + ", errorCode=" + errorCode + ", msg='" + msg + "', extra=" + extra + '}';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import java.io.Serializable;
|
|
4
|
+
|
|
5
|
+
public class CustomMessage implements Serializable {
|
|
6
|
+
private static final long serialVersionUID = 1L;
|
|
7
|
+
|
|
8
|
+
public String messageId;
|
|
9
|
+
public String extra;
|
|
10
|
+
public String message;
|
|
11
|
+
public String contentType;
|
|
12
|
+
public String title;
|
|
13
|
+
public String senderId;
|
|
14
|
+
public String appId;
|
|
15
|
+
public byte platform;
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public String toString() {
|
|
19
|
+
return "CustomMessage{messageId='" + messageId
|
|
20
|
+
+ "', extra='" + extra
|
|
21
|
+
+ "', message='" + message
|
|
22
|
+
+ "', contentType='" + contentType
|
|
23
|
+
+ "', title='" + title
|
|
24
|
+
+ "', senderId='" + senderId
|
|
25
|
+
+ "', appId='" + appId
|
|
26
|
+
+ "', platform='" + platform + "'}";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.pm.ApplicationInfo;
|
|
5
|
+
import android.widget.RemoteViews;
|
|
6
|
+
|
|
7
|
+
public class CustomPushNotificationBuilder extends BasicPushNotificationBuilder {
|
|
8
|
+
public int layoutTimeId;
|
|
9
|
+
public int layout;
|
|
10
|
+
public int layoutIconId;
|
|
11
|
+
public int layoutTitleId;
|
|
12
|
+
public int layoutContentId;
|
|
13
|
+
public int layoutIconDrawable = 0;
|
|
14
|
+
|
|
15
|
+
CustomPushNotificationBuilder(Context context) {
|
|
16
|
+
super(context);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public CustomPushNotificationBuilder(Context context, int layout, int layoutIconId, int layoutTitleId, int layoutContentId, int layoutTimeId) {
|
|
20
|
+
super(context);
|
|
21
|
+
this.layout = layout;
|
|
22
|
+
this.layoutIconId = layoutIconId;
|
|
23
|
+
this.layoutTitleId = layoutTitleId;
|
|
24
|
+
this.layoutContentId = layoutContentId;
|
|
25
|
+
this.layoutTimeId = layoutTimeId;
|
|
26
|
+
try {
|
|
27
|
+
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
|
|
28
|
+
if (appInfo != null) {
|
|
29
|
+
this.layoutIconDrawable = appInfo.icon;
|
|
30
|
+
}
|
|
31
|
+
} catch (Throwable ignored) {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public CustomPushNotificationBuilder(Context context, int layout, int layoutIconId, int layoutTitleId, int layoutContentId) {
|
|
36
|
+
this(context, layout, layoutIconId, layoutTitleId, layoutContentId, 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
RemoteViews buildContentView(String content, String title) {
|
|
41
|
+
RemoteViews remoteViews = new RemoteViews(this.builderContext.getPackageName(), this.layout);
|
|
42
|
+
remoteViews.setTextViewText(this.layoutTitleId, title);
|
|
43
|
+
remoteViews.setImageViewResource(this.layoutIconId, this.layoutIconDrawable);
|
|
44
|
+
remoteViews.setTextViewText(this.layoutContentId, content);
|
|
45
|
+
if (this.layoutTimeId != 0) {
|
|
46
|
+
remoteViews.setLong(this.layoutTimeId, "setTime", System.currentTimeMillis());
|
|
47
|
+
}
|
|
48
|
+
return remoteViews;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public String toString() {
|
|
53
|
+
return "custom_____" + serializeFields();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@Override
|
|
57
|
+
String serializeFields() {
|
|
58
|
+
return super.serializeFields()
|
|
59
|
+
+ "_____" + this.layout
|
|
60
|
+
+ "_____" + this.layoutIconId
|
|
61
|
+
+ "_____" + this.layoutTitleId
|
|
62
|
+
+ "_____" + this.layoutContentId
|
|
63
|
+
+ "_____" + this.layoutIconDrawable
|
|
64
|
+
+ "_____" + this.layoutTimeId;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
void parseFields(String[] parts) {
|
|
69
|
+
super.parseFields(parts);
|
|
70
|
+
if (parts.length >= 10) {
|
|
71
|
+
this.layout = Integer.parseInt(parts[5]);
|
|
72
|
+
this.layoutIconId = Integer.parseInt(parts[6]);
|
|
73
|
+
this.layoutTitleId = Integer.parseInt(parts[7]);
|
|
74
|
+
this.layoutContentId = Integer.parseInt(parts[8]);
|
|
75
|
+
this.layoutIconDrawable = Integer.parseInt(parts[9]);
|
|
76
|
+
}
|
|
77
|
+
if (parts.length >= 11) {
|
|
78
|
+
this.layoutTimeId = Integer.parseInt(parts[10]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
package cn.jpush.android.api;
|
|
2
|
+
|
|
3
|
+
import android.app.Notification;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.os.Build;
|
|
6
|
+
import android.text.TextUtils;
|
|
7
|
+
import android.widget.RemoteViews;
|
|
8
|
+
import java.util.HashMap;
|
|
9
|
+
import java.util.Map;
|
|
10
|
+
|
|
11
|
+
public class DefaultPushNotificationBuilder implements PushNotificationBuilder {
|
|
12
|
+
public static final int NOTI_STYLE_BIG_TEXT = 1;
|
|
13
|
+
public static final int NOTI_STYLE_INBOX = 2;
|
|
14
|
+
public static final int NOTI_STYLE_BIG_PICTURE = 3;
|
|
15
|
+
|
|
16
|
+
protected Context context;
|
|
17
|
+
protected NotificationMessage notificationMessage;
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public Notification buildNotification(Context context, NotificationMessage message) {
|
|
21
|
+
this.context = context;
|
|
22
|
+
this.notificationMessage = message;
|
|
23
|
+
Map<String, String> params = new HashMap<String, String>();
|
|
24
|
+
if (message != null) {
|
|
25
|
+
params.put(JPushInterface.EXTRA_MSG_ID, message.msgId);
|
|
26
|
+
params.put(JPushInterface.EXTRA_ALERT, message.notificationContent);
|
|
27
|
+
params.put(JPushInterface.EXTRA_ALERT_TYPE, String.valueOf(message.notificationAlertType));
|
|
28
|
+
if (!TextUtils.isEmpty(message.notificationTitle)) {
|
|
29
|
+
params.put(JPushInterface.EXTRA_NOTIFICATION_TITLE, message.notificationTitle);
|
|
30
|
+
}
|
|
31
|
+
if (!TextUtils.isEmpty(message.notificationExtras)) {
|
|
32
|
+
params.put(JPushInterface.EXTRA_EXTRA, message.notificationExtras);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return buildNotification(params);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public Notification buildNotification(Map<String, String> params) {
|
|
40
|
+
if (this.context == null || params == null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
String alert = params.get(JPushInterface.EXTRA_ALERT);
|
|
44
|
+
if (TextUtils.isEmpty(alert)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
String title = params.get(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
|
48
|
+
if (TextUtils.isEmpty(title)) {
|
|
49
|
+
try {
|
|
50
|
+
title = this.context.getApplicationInfo().loadLabel(this.context.getPackageManager()).toString();
|
|
51
|
+
} catch (Throwable ignored) {
|
|
52
|
+
title = "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Notification.Builder builder = new Notification.Builder(this.context);
|
|
57
|
+
builder.setContentTitle(title).setContentText(alert).setTicker(alert);
|
|
58
|
+
int iconRes = this.context.getApplicationInfo() != null ? this.context.getApplicationInfo().icon : 0;
|
|
59
|
+
builder.setSmallIcon(iconRes != 0 ? iconRes : android.R.color.transparent);
|
|
60
|
+
if (Build.VERSION.SDK_INT >= 17) {
|
|
61
|
+
builder.setShowWhen(true);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
RemoteViews customView = buildContentView(alert, title);
|
|
65
|
+
if (customView != null) {
|
|
66
|
+
builder.setContent(customView);
|
|
67
|
+
}
|
|
68
|
+
Notification notification = getNotification(builder);
|
|
69
|
+
if (notification != null) {
|
|
70
|
+
resetNotificationParams(notification);
|
|
71
|
+
}
|
|
72
|
+
return notification;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
RemoteViews buildContentView(String content, String title) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void resetNotificationParams(Notification notification) {
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Notification getNotification(Notification.Builder builder) {
|
|
83
|
+
return builder.build();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Override
|
|
87
|
+
public String getDeveloperArg0() {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|