@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.
Files changed (178) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -2
  3. package/ReactNativeJpush.podspec +66 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +143 -0
  6. package/android/fcm/build.gradle +29 -0
  7. package/android/fcm/consumer-rules.pro +2 -0
  8. package/android/fcm/src/main/AndroidManifest.xml +16 -0
  9. package/android/fcm/src/main/java/com/onekey/jpush/fcm/FcmMessagingService.java +72 -0
  10. package/android/fcm/src/main/java/com/onekey/jpush/fcm/FcmPushManager.java +69 -0
  11. package/android/gradle.properties +4 -0
  12. package/android/src/main/AndroidManifest.xml +143 -0
  13. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  14. package/android/src/main/java/cn/android/service/JTransitActivity.java +19 -0
  15. package/android/src/main/java/cn/jiguang/android/BuildConfig.java +10 -0
  16. package/android/src/main/java/cn/jiguang/android/IDataShare.java +190 -0
  17. package/android/src/main/java/cn/jiguang/api/BaseLogger.java +82 -0
  18. package/android/src/main/java/cn/jiguang/api/JAction.java +22 -0
  19. package/android/src/main/java/cn/jiguang/api/JActionExtra.java +21 -0
  20. package/android/src/main/java/cn/jiguang/api/JAnalyticsAction.java +11 -0
  21. package/android/src/main/java/cn/jiguang/api/JCoreInterface.java +228 -0
  22. package/android/src/main/java/cn/jiguang/api/JCoreManager.java +156 -0
  23. package/android/src/main/java/cn/jiguang/api/JDispatchAction.java +66 -0
  24. package/android/src/main/java/cn/jiguang/api/MultiSpHelper.java +114 -0
  25. package/android/src/main/java/cn/jiguang/api/ReportCallBack.java +9 -0
  26. package/android/src/main/java/cn/jiguang/api/SdkType.java +13 -0
  27. package/android/src/main/java/cn/jiguang/api/utils/JCollectionAuth.java +23 -0
  28. package/android/src/main/java/cn/jiguang/core/JCoreCrypto.java +545 -0
  29. package/android/src/main/java/cn/jiguang/core/JCoreStorage.java +737 -0
  30. package/android/src/main/java/cn/jiguang/core/JCoreTcpEngine.java +1395 -0
  31. package/android/src/main/java/cn/jiguang/core/JCoreWireCodec.java +1716 -0
  32. package/android/src/main/java/cn/jiguang/internal/ActionManager.java +63 -0
  33. package/android/src/main/java/cn/jiguang/internal/JConstants.java +61 -0
  34. package/android/src/main/java/cn/jiguang/internal/JCoreHelperAction.java +12 -0
  35. package/android/src/main/java/cn/jiguang/internal/JCoreInternalHelper.java +102 -0
  36. package/android/src/main/java/cn/jiguang/net/DefaultHostVerifier.java +40 -0
  37. package/android/src/main/java/cn/jiguang/net/HttpRequest.java +78 -0
  38. package/android/src/main/java/cn/jiguang/net/HttpResponse.java +48 -0
  39. package/android/src/main/java/cn/jiguang/net/HttpUtils.java +106 -0
  40. package/android/src/main/java/cn/jiguang/plugins/core/JCoreModule.java +91 -0
  41. package/android/src/main/java/cn/jiguang/plugins/core/JCorePackage.java +27 -0
  42. package/android/src/main/java/cn/jiguang/plugins/push/JPushModule.java +773 -0
  43. package/android/src/main/java/cn/jiguang/plugins/push/JPushPackage.java +25 -0
  44. package/android/src/main/java/cn/jiguang/plugins/push/common/JConstants.java +88 -0
  45. package/android/src/main/java/cn/jiguang/plugins/push/common/JLogger.java +122 -0
  46. package/android/src/main/java/cn/jiguang/plugins/push/helper/JPushHelper.java +710 -0
  47. package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushBroadcastReceiver.java +37 -0
  48. package/android/src/main/java/cn/jiguang/plugins/push/receiver/JPushModuleReceiver.java +264 -0
  49. package/android/src/main/java/cn/jiguang/plugins/service/JCoreModuleService.java +7 -0
  50. package/android/src/main/java/cn/jpush/android/api/BasicPushNotificationBuilder.java +83 -0
  51. package/android/src/main/java/cn/jpush/android/api/CallBackParams.java +50 -0
  52. package/android/src/main/java/cn/jpush/android/api/CmdMessage.java +33 -0
  53. package/android/src/main/java/cn/jpush/android/api/CustomMessage.java +28 -0
  54. package/android/src/main/java/cn/jpush/android/api/CustomPushNotificationBuilder.java +81 -0
  55. package/android/src/main/java/cn/jpush/android/api/DefaultPushNotificationBuilder.java +90 -0
  56. package/android/src/main/java/cn/jpush/android/api/InAppSlotParams.java +65 -0
  57. package/android/src/main/java/cn/jpush/android/api/InstrumentedActivity.java +17 -0
  58. package/android/src/main/java/cn/jpush/android/api/InstrumentedListActivity.java +17 -0
  59. package/android/src/main/java/cn/jpush/android/api/JPushInterface.java +490 -0
  60. package/android/src/main/java/cn/jpush/android/api/JPushMessage.java +121 -0
  61. package/android/src/main/java/cn/jpush/android/api/JThirdPlatFormInterface.java +247 -0
  62. package/android/src/main/java/cn/jpush/android/api/MultiActionsNotificationBuilder.java +72 -0
  63. package/android/src/main/java/cn/jpush/android/api/NotificationCustomButton.java +50 -0
  64. package/android/src/main/java/cn/jpush/android/api/NotificationMessage.java +67 -0
  65. package/android/src/main/java/cn/jpush/android/api/PushNotificationBuilder.java +13 -0
  66. package/android/src/main/java/cn/jpush/android/api/TagAliasCallback.java +8 -0
  67. package/android/src/main/java/cn/jpush/android/data/JPushCollectControl.java +96 -0
  68. package/android/src/main/java/cn/jpush/android/data/JPushConfig.java +79 -0
  69. package/android/src/main/java/cn/jpush/android/data/JPushConfigEx.java +41 -0
  70. package/android/src/main/java/cn/jpush/android/data/JPushLocalNotification.java +155 -0
  71. package/android/src/main/java/cn/jpush/android/helper/JCoreHelper.java +70 -0
  72. package/android/src/main/java/cn/jpush/android/helper/Logger.java +82 -0
  73. package/android/src/main/java/cn/jpush/android/local/ActionHelper.java +1277 -0
  74. package/android/src/main/java/cn/jpush/android/local/ActivityLifeCallBack.java +47 -0
  75. package/android/src/main/java/cn/jpush/android/local/JPushAction.java +67 -0
  76. package/android/src/main/java/cn/jpush/android/local/JPushConstants.java +34 -0
  77. package/android/src/main/java/cn/jpush/android/local/JPushResponse.java +26 -0
  78. package/android/src/main/java/cn/jpush/android/local/ProxyActivityAction.java +34 -0
  79. package/android/src/main/java/cn/jpush/android/service/AlarmReceiver.java +15 -0
  80. package/android/src/main/java/cn/jpush/android/service/BActivity.java +19 -0
  81. package/android/src/main/java/cn/jpush/android/service/DActivity.java +19 -0
  82. package/android/src/main/java/cn/jpush/android/service/DaemonService.java +17 -0
  83. package/android/src/main/java/cn/jpush/android/service/DataProvider.java +136 -0
  84. package/android/src/main/java/cn/jpush/android/service/DataShare.java +129 -0
  85. package/android/src/main/java/cn/jpush/android/service/DownloadProvider.java +139 -0
  86. package/android/src/main/java/cn/jpush/android/service/InitProvider.java +48 -0
  87. package/android/src/main/java/cn/jpush/android/service/JCommonService.java +79 -0
  88. package/android/src/main/java/cn/jpush/android/service/JNotifyActivity.java +28 -0
  89. package/android/src/main/java/cn/jpush/android/service/JPushMessageReceiver.java +94 -0
  90. package/android/src/main/java/cn/jpush/android/service/PushReceiver.java +26 -0
  91. package/android/src/main/java/cn/jpush/android/service/PushService.java +28 -0
  92. package/android/src/main/java/cn/jpush/android/service/SchedulerReceiver.java +17 -0
  93. package/android/src/main/java/cn/jpush/android/service/TagAliasReceiver.java +11 -0
  94. package/android/src/main/java/cn/jpush/android/service/WakedResultReceiver.java +24 -0
  95. package/android/src/main/java/cn/jpush/android/ui/FullScreenView.java +11 -0
  96. package/android/src/main/java/cn/jpush/android/ui/PopWinActivity.java +16 -0
  97. package/android/src/main/java/cn/jpush/android/ui/PushActivity.java +27 -0
  98. package/android/src/main/java/cn/jpush/android/ui/RoundedImageView.java +63 -0
  99. package/android/src/main/java/cn/jpush/android/ui/ShadowViewCard.java +56 -0
  100. package/android/src/main/java/cn/jpush/android/ups/ICallbackResult.java +5 -0
  101. package/android/src/main/java/cn/jpush/android/ups/JPushUPSManager.java +37 -0
  102. package/android/src/main/java/cn/jpush/android/ups/TokenResult.java +47 -0
  103. package/android/src/main/java/cn/jpush/android/ups/UPSRegisterCallBack.java +4 -0
  104. package/android/src/main/java/cn/jpush/android/ups/UPSTurnCallBack.java +4 -0
  105. package/android/src/main/java/cn/jpush/android/ups/UPSUnRegisterCallBack.java +4 -0
  106. package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpush.kt +455 -0
  107. package/android/src/main/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushPackage.kt +50 -0
  108. package/android/src/main/res/values/jpush_string.xml +7 -0
  109. package/android/src/main/res/values/jpush_style.xml +22 -0
  110. package/android/src/test/java/com/margelo/nitro/reactnativejpush/ReactNativeJpushProtocolTest.java +1016 -0
  111. package/ios/ReactNativeJpush.swift +522 -0
  112. package/ios/bridge/RCTJCoreModule.h +5 -0
  113. package/ios/bridge/RCTJCoreModule.m +31 -0
  114. package/ios/bridge/RCTJPushEventQueue.h +14 -0
  115. package/ios/bridge/RCTJPushEventQueue.m +23 -0
  116. package/ios/bridge/RCTJPushModule.h +37 -0
  117. package/ios/bridge/RCTJPushModule.m +1165 -0
  118. package/ios/include/JCOREService.h +3 -0
  119. package/ios/include/JGCOREAPI.h +14 -0
  120. package/ios/include/JGInforCollectionAuth.h +17 -0
  121. package/ios/include/JGInforCollectionAuthItems.h +2 -0
  122. package/ios/include/JGPushNotificationTrigger.h +2 -0
  123. package/ios/include/JPUSHService.h +359 -0
  124. package/ios/jcore/JCOREConfiguration.h +141 -0
  125. package/ios/jcore/JCOREConfiguration.m +703 -0
  126. package/ios/jcore/JCORECrypto.h +73 -0
  127. package/ios/jcore/JCORECrypto.m +649 -0
  128. package/ios/jcore/JCORESisResolver.h +56 -0
  129. package/ios/jcore/JCORESisResolver.m +525 -0
  130. package/ios/jcore/JCORETcpSession.h +42 -0
  131. package/ios/jcore/JCORETcpSession.m +956 -0
  132. package/ios/jcore/JCOREWireProtocol.h +274 -0
  133. package/ios/jcore/JCOREWireProtocol.m +1453 -0
  134. package/ios/jpush/JPUSHModels.m +214 -0
  135. package/ios/jpush/JPUSHNotificationManager.h +34 -0
  136. package/ios/jpush/JPUSHNotificationManager.m +360 -0
  137. package/ios/jpush/JPUSHService.m +794 -0
  138. package/ios/tests/ReactNativeJpushTests.m +148 -0
  139. package/lib/module/ReactNativeJpush.nitro.js +4 -0
  140. package/lib/module/ReactNativeJpush.nitro.js.map +1 -0
  141. package/lib/module/index.js +801 -0
  142. package/lib/module/index.js.map +1 -0
  143. package/lib/module/package.json +1 -0
  144. package/lib/typescript/package.json +1 -0
  145. package/lib/typescript/src/ReactNativeJpush.nitro.d.ts +60 -0
  146. package/lib/typescript/src/ReactNativeJpush.nitro.d.ts.map +1 -0
  147. package/lib/typescript/src/index.d.ts +235 -0
  148. package/lib/typescript/src/index.d.ts.map +1 -0
  149. package/nitro.json +23 -0
  150. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  151. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string.hpp +76 -0
  152. package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.cpp +310 -0
  153. package/nitrogen/generated/android/c++/JHybridReactNativeJpushSpec.hpp +115 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_bool.kt +78 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/Func_void_std__string_std__string.kt +78 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/HybridReactNativeJpushSpec.kt +274 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativejpush/reactnativejpushOnLoad.kt +35 -0
  158. package/nitrogen/generated/android/reactnativejpush+autolinking.cmake +81 -0
  159. package/nitrogen/generated/android/reactnativejpush+autolinking.gradle +27 -0
  160. package/nitrogen/generated/android/reactnativejpushOnLoad.cpp +58 -0
  161. package/nitrogen/generated/android/reactnativejpushOnLoad.hpp +34 -0
  162. package/nitrogen/generated/ios/ReactNativeJpush+autolinking.rb +62 -0
  163. package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.cpp +49 -0
  164. package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Bridge.hpp +147 -0
  165. package/nitrogen/generated/ios/ReactNativeJpush-Swift-Cxx-Umbrella.hpp +46 -0
  166. package/nitrogen/generated/ios/ReactNativeJpushAutolinking.mm +33 -0
  167. package/nitrogen/generated/ios/ReactNativeJpushAutolinking.swift +26 -0
  168. package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.cpp +11 -0
  169. package/nitrogen/generated/ios/c++/HybridReactNativeJpushSpecSwift.hpp +402 -0
  170. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  171. package/nitrogen/generated/ios/swift/Func_void_std__string_std__string.swift +46 -0
  172. package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec.swift +107 -0
  173. package/nitrogen/generated/ios/swift/HybridReactNativeJpushSpec_cxx.swift +723 -0
  174. package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.cpp +73 -0
  175. package/nitrogen/generated/shared/c++/HybridReactNativeJpushSpec.hpp +116 -0
  176. package/package.json +174 -4
  177. package/src/ReactNativeJpush.nitro.ts +93 -0
  178. package/src/index.tsx +1090 -0
@@ -0,0 +1,1165 @@
1
+ #import "RCTJPushModule.h"
2
+ #if __has_include("JCOREConfiguration.h")
3
+ #import "JCOREConfiguration.h"
4
+ #else
5
+ #import "../jcore/JCOREConfiguration.h"
6
+ #endif
7
+ #if __has_include("JPUSHNotificationManager.h")
8
+ #import "JPUSHNotificationManager.h"
9
+ #elif __has_include("../jpush/JPUSHNotificationManager.h")
10
+ #import "../jpush/JPUSHNotificationManager.h"
11
+ #endif
12
+ #import <UIKit/UIKit.h>
13
+ #import <UserNotifications/UserNotifications.h>
14
+
15
+ #if __has_include(<React/RCTBridge.h>)
16
+ #import <React/RCTBridge.h>
17
+ #elif __has_include("RCTBridge.h")
18
+ #import "RCTBridge.h"
19
+ #endif
20
+
21
+ #define CODE @"code"
22
+ #define BADGE @"badge"
23
+ #define SEQUENCE @"sequence"
24
+ #define REGISTER_ID @"registerID"
25
+ #define MOBILE_NUMBER @"mobileNumber"
26
+ #define CONNECT_ENABLE @"connectEnable"
27
+
28
+ #define MESSAGE_ID @"messageID"
29
+ #define TITLE @"title"
30
+ #define CONTENT @"content"
31
+ #define EXTRAS @"extras"
32
+ #define RING @"ring"
33
+ #define BROADCASTTIME @"broadcastTime"
34
+ #define APP_BADGE @"appBadge"
35
+
36
+ #define TAG @"tag"
37
+ #define TAGS @"tags"
38
+ #define TAG_ENABLE @"tagEnable"
39
+ #define ALIAS @"alias"
40
+ #define PROS @"pros"
41
+
42
+ #define GEO_FENCE_ID @"geoFenceID"
43
+ #define GEO_FENCE_MAX_NUMBER @"geoFenceMaxNumber"
44
+
45
+ #define NOTIFICATION_EVENT_TYPE @"notificationEventType"
46
+ #define NOTIFICATION_ARRIVED @"notificationArrived"
47
+ #define NOTIFICATION_OPENED @"notificationOpened"
48
+ #define NOTIFICATION_DISMISSED @"notificationDismissed"
49
+ #define NOTIFICATION_EVENT @"NotificationEvent"
50
+ #define CUSTOM_MESSAGE_EVENT @"CustomMessageEvent"
51
+ #define INAPP_MESSAGE_EVENT_TYPE @"inappEventType"
52
+ #define INAPP_MESSAGE_SHOW @"inappShow"
53
+ #define INAPP_MESSAGE_CLICK @"inappClick"
54
+ #define INAPP_MESSAGE_EVENT @"InappMessageEvent"
55
+ #define LOCAL_NOTIFICATION_EVENT @"LocalNotificationEvent"
56
+ #define CONNECT_EVENT @"ConnectEvent"
57
+ #define TAG_ALIAS_EVENT @"TagAliasEvent"
58
+ #define PROPERTIES_EVENT @"PropertiesEvent"
59
+ #define MOBILE_NUMBER_EVENT @"MobileNumberEvent"
60
+
61
+ static __weak RCTJPushModule *sSharedJPushModule = nil;
62
+ static NSHashTable<RCTJPushModule *> *sActiveModules = nil;
63
+ static NSMutableArray<NSDictionary *> *sPendingEvents = nil;
64
+ static NSMutableArray<NSDictionary *> *sPendingNitroEvents = nil;
65
+ static NSMutableDictionary<NSNumber *, RCTJPushNitroEventListener> *sNitroListeners = nil;
66
+ static NSInteger sNextNitroListenerId = 1;
67
+ static RCTJPushModule *sNotificationObserverHelper = nil;
68
+
69
+ @interface NSObject (RCTJPushBridgelessCompat)
70
+ - (instancetype)initWithDisabledObservation;
71
+ - (nullable id)callableJSModules;
72
+ - (void)invokeModule:(NSString *)moduleName method:(NSString *)methodName withArgs:(NSArray *)args;
73
+ - (void)sendEventWithName:(NSString *)eventName body:(id)body;
74
+ @end
75
+
76
+ @interface RCTJPushModule () <RCTBridgeModule, JPUSHRegisterDelegate, JPUSHInAppMessageDelegate> {
77
+ BOOL _hasListeners;
78
+ }
79
+ @property (nonatomic, weak, nullable) RCTBridge *bridge;
80
+ @end
81
+
82
+ @implementation RCTJPushModule
83
+
84
+ @synthesize bridge = _bridge;
85
+
86
+ RCT_EXPORT_MODULE(JPushModule);
87
+
88
+ + (void)registerActiveModule:(RCTJPushModule *)module {
89
+ if (module == nil) {
90
+ return;
91
+ }
92
+ @synchronized (RCTJPushModule.class) {
93
+ if (sActiveModules == nil) {
94
+ sActiveModules = [NSHashTable weakObjectsHashTable];
95
+ }
96
+ [sActiveModules addObject:module];
97
+ sSharedJPushModule = module;
98
+ }
99
+ }
100
+
101
+ + (NSArray<RCTJPushModule *> *)allActiveModules {
102
+ @synchronized (RCTJPushModule.class) {
103
+ NSMutableArray<RCTJPushModule *> *list = [NSMutableArray array];
104
+ if (sActiveModules != nil) {
105
+ for (RCTJPushModule *mod in sActiveModules) {
106
+ if (mod != nil && ![list containsObject:mod]) {
107
+ [list addObject:mod];
108
+ }
109
+ }
110
+ }
111
+ RCTJPushModule *shared = sSharedJPushModule;
112
+ if (shared != nil && ![list containsObject:shared]) {
113
+ [list addObject:shared];
114
+ }
115
+ return [list copy];
116
+ }
117
+ }
118
+
119
+ + (void)clearActiveModules {
120
+ @synchronized (RCTJPushModule.class) {
121
+ [sActiveModules removeAllObjects];
122
+ [sNitroListeners removeAllObjects];
123
+ [sPendingEvents removeAllObjects];
124
+ [sPendingNitroEvents removeAllObjects];
125
+ sSharedJPushModule = nil;
126
+ }
127
+ }
128
+
129
+ + (void)ensureSharedNativeObservers {
130
+ @synchronized (RCTJPushModule.class) {
131
+ if (sNotificationObserverHelper == nil) {
132
+ sNotificationObserverHelper = [[RCTJPushModule alloc] initAsSharedObserver];
133
+ }
134
+ }
135
+ }
136
+
137
+ + (void)setupOrRefreshJPushNativeState {
138
+ [self ensureSharedNativeObservers];
139
+ [sNotificationObserverHelper setupOrRefreshJPushNativeState];
140
+ }
141
+
142
+ + (NSInteger)registerNitroEventListener:(RCTJPushNitroEventListener)listener {
143
+ if (listener == nil) {
144
+ return 0;
145
+ }
146
+ [self ensureSharedNativeObservers];
147
+ NSInteger listenerId = 0;
148
+ @synchronized (RCTJPushModule.class) {
149
+ if (sNitroListeners == nil) {
150
+ sNitroListeners = [NSMutableDictionary dictionary];
151
+ }
152
+ listenerId = sNextNitroListenerId++;
153
+ sNitroListeners[@(listenerId)] = [listener copy];
154
+ }
155
+ [self flushQueuedNotifications];
156
+ return listenerId;
157
+ }
158
+
159
+ + (void)unregisterNitroEventListener:(NSInteger)listenerId {
160
+ if (listenerId <= 0) {
161
+ return;
162
+ }
163
+ @synchronized (RCTJPushModule.class) {
164
+ [sNitroListeners removeObjectForKey:@(listenerId)];
165
+ }
166
+ }
167
+
168
+ + (NSString *)dictionaryToJsonString:(NSDictionary *)dict {
169
+ if (![dict isKindOfClass:[NSDictionary class]] || dict.count == 0) {
170
+ return @"{}";
171
+ }
172
+ @try {
173
+ if ([NSJSONSerialization isValidJSONObject:dict]) {
174
+ NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
175
+ if (data.length > 0) {
176
+ NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
177
+ if (json.length > 0) {
178
+ return json;
179
+ }
180
+ }
181
+ }
182
+ } @catch (NSException *exception) {
183
+ }
184
+ return @"{}";
185
+ }
186
+
187
+ + (BOOL)hasReadyEventConsumer {
188
+ @synchronized (RCTJPushModule.class) {
189
+ if (sNitroListeners.count > 0) {
190
+ return YES;
191
+ }
192
+ }
193
+ NSArray<RCTJPushModule *> *modules = [self allActiveModules];
194
+ for (RCTJPushModule *mod in modules) {
195
+ if ([mod canEmitEventsNow]) {
196
+ return YES;
197
+ }
198
+ }
199
+ return NO;
200
+ }
201
+
202
+ - (void)setBridge:(RCTBridge *)bridge {
203
+ _bridge = bridge;
204
+ [RCTJPushModule registerActiveModule:self];
205
+ if (bridge != nil) {
206
+ [RCTJPushModule flushPendingBridgeEvents];
207
+ }
208
+ }
209
+
210
+ - (void)startObserving {
211
+ _hasListeners = YES;
212
+ [RCTJPushModule registerActiveModule:self];
213
+ [RCTJPushModule flushQueuedNotifications];
214
+ }
215
+
216
+ - (void)stopObserving {
217
+ _hasListeners = NO;
218
+ }
219
+
220
+ RCT_EXPORT_METHOD(addListener:(NSString *)eventName) {
221
+ (void)eventName;
222
+ [self startObserving];
223
+ }
224
+
225
+ RCT_EXPORT_METHOD(removeListeners:(double)count) {
226
+ (void)count;
227
+ }
228
+
229
+ + (BOOL)requiresMainQueueSetup {
230
+ return YES;
231
+ }
232
+
233
+ + (nullable instancetype)sharedModule {
234
+ return sSharedJPushModule;
235
+ }
236
+
237
+ - (BOOL)canEmitEventsNow {
238
+ if (self.bridge != nil) {
239
+ return YES;
240
+ }
241
+ if ([self respondsToSelector:@selector(callableJSModules)]) {
242
+ id callableModules = [self callableJSModules];
243
+ if (callableModules != nil && [callableModules respondsToSelector:@selector(invokeModule:method:withArgs:)]) {
244
+ return YES;
245
+ }
246
+ }
247
+ if (_hasListeners && [self respondsToSelector:@selector(sendEventWithName:body:)]) {
248
+ return YES;
249
+ }
250
+ return NO;
251
+ }
252
+
253
+ - (BOOL)emitToDeviceEventEmitter:(NSString *)eventName payload:(NSDictionary *)payload {
254
+ if (eventName.length == 0) {
255
+ return NO;
256
+ }
257
+ NSDictionary *safePayload = payload ?: @{};
258
+ if (self.bridge != nil) {
259
+ [self.bridge enqueueJSCall:@"RCTDeviceEventEmitter"
260
+ method:@"emit"
261
+ args:@[eventName, safePayload]
262
+ completion:NULL];
263
+ return YES;
264
+ }
265
+ if ([self respondsToSelector:@selector(callableJSModules)]) {
266
+ id callableModules = [self callableJSModules];
267
+ if (callableModules != nil && [callableModules respondsToSelector:@selector(invokeModule:method:withArgs:)]) {
268
+ [callableModules invokeModule:@"RCTDeviceEventEmitter"
269
+ method:@"emit"
270
+ withArgs:@[eventName, safePayload]];
271
+ return YES;
272
+ }
273
+ }
274
+ if (_hasListeners && [self respondsToSelector:@selector(sendEventWithName:body:)]) {
275
+ [self sendEventWithName:eventName body:safePayload];
276
+ return YES;
277
+ }
278
+ return NO;
279
+ }
280
+
281
+ + (void)emitEventWithName:(NSString *)eventName payload:(NSDictionary *)payload {
282
+ if (eventName.length == 0) {
283
+ return;
284
+ }
285
+ [self ensureSharedNativeObservers];
286
+ NSDictionary *safePayload = payload ?: @{};
287
+ NSArray<RCTJPushModule *> *modules = [self allActiveModules];
288
+ BOOL emittedToLegacy = NO;
289
+ for (RCTJPushModule *module in modules) {
290
+ if ([module emitToDeviceEventEmitter:eventName payload:safePayload]) {
291
+ emittedToLegacy = YES;
292
+ }
293
+ }
294
+ if (!emittedToLegacy) {
295
+ @synchronized (RCTJPushModule.class) {
296
+ if (sPendingEvents == nil) {
297
+ sPendingEvents = [NSMutableArray array];
298
+ }
299
+ if (sPendingEvents.count >= 64) {
300
+ [sPendingEvents removeObjectAtIndex:0];
301
+ }
302
+ [sPendingEvents addObject:@{
303
+ @"name": eventName,
304
+ @"payload": safePayload,
305
+ }];
306
+ }
307
+ }
308
+
309
+ NSString *payloadJson = [self dictionaryToJsonString:safePayload];
310
+ NSArray<RCTJPushNitroEventListener> *nitroListeners = nil;
311
+ @synchronized (RCTJPushModule.class) {
312
+ if (sNitroListeners.count > 0) {
313
+ nitroListeners = [sNitroListeners.allValues copy];
314
+ } else {
315
+ if (sPendingNitroEvents == nil) {
316
+ sPendingNitroEvents = [NSMutableArray array];
317
+ }
318
+ if (sPendingNitroEvents.count >= 64) {
319
+ [sPendingNitroEvents removeObjectAtIndex:0];
320
+ }
321
+ [sPendingNitroEvents addObject:@{
322
+ @"name": eventName,
323
+ @"json": payloadJson,
324
+ }];
325
+ }
326
+ }
327
+ for (RCTJPushNitroEventListener listener in nitroListeners) {
328
+ listener(eventName, payloadJson);
329
+ }
330
+ }
331
+
332
+ + (void)flushPendingNitroEvents {
333
+ NSArray<RCTJPushNitroEventListener> *nitroListeners = nil;
334
+ NSArray<NSDictionary *> *pendingNitroSnapshot = nil;
335
+ @synchronized (RCTJPushModule.class) {
336
+ if (sNitroListeners.count > 0 && sPendingNitroEvents.count > 0) {
337
+ nitroListeners = [sNitroListeners.allValues copy];
338
+ pendingNitroSnapshot = [sPendingNitroEvents copy];
339
+ [sPendingNitroEvents removeAllObjects];
340
+ }
341
+ }
342
+ for (NSDictionary *item in pendingNitroSnapshot) {
343
+ NSString *name = item[@"name"];
344
+ NSString *json = item[@"json"] ?: @"{}";
345
+ if (name.length > 0) {
346
+ for (RCTJPushNitroEventListener listener in nitroListeners) {
347
+ listener(name, json);
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ + (void)flushPendingBridgeEvents {
354
+ [self ensureSharedNativeObservers];
355
+ [self flushPendingNitroEvents];
356
+
357
+ NSArray<RCTJPushModule *> *modules = [self allActiveModules];
358
+ BOOL hasReadyLegacy = NO;
359
+ for (RCTJPushModule *mod in modules) {
360
+ if ([mod canEmitEventsNow]) {
361
+ hasReadyLegacy = YES;
362
+ break;
363
+ }
364
+ }
365
+ if (!hasReadyLegacy) {
366
+ return;
367
+ }
368
+
369
+ NSArray<NSDictionary *> *pendingSnapshot = nil;
370
+ @synchronized (RCTJPushModule.class) {
371
+ if (sPendingEvents.count > 0) {
372
+ pendingSnapshot = [sPendingEvents copy];
373
+ [sPendingEvents removeAllObjects];
374
+ }
375
+ }
376
+ for (NSDictionary *item in pendingSnapshot) {
377
+ NSString *name = item[@"name"];
378
+ NSDictionary *payload = item[@"payload"] ?: @{};
379
+ if (name.length > 0) {
380
+ for (RCTJPushModule *module in modules) {
381
+ [module emitToDeviceEventEmitter:name payload:payload];
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ + (void)flushQueuedNotifications {
388
+ [self ensureSharedNativeObservers];
389
+ [self flushPendingBridgeEvents];
390
+
391
+ RCTJPushModule *converter = sNotificationObserverHelper ?: [self allActiveModules].firstObject;
392
+ NSMutableArray *notificationList = [RCTJPushEventQueue sharedInstance]._notificationQueue;
393
+ if (notificationList.count > 0) {
394
+ NSArray *queuedApns = [notificationList copy];
395
+ [notificationList removeAllObjects];
396
+ for (id obj in queuedApns) {
397
+ if ([obj isKindOfClass:[NSDictionary class]]) {
398
+ [converter sendApnsNotificationEventByDictionary:(NSDictionary *)obj];
399
+ }
400
+ }
401
+ }
402
+ NSMutableArray *localNotificationList = [RCTJPushEventQueue sharedInstance]._localNotificationQueue;
403
+ if (localNotificationList.count > 0) {
404
+ NSArray *queuedLocal = [localNotificationList copy];
405
+ [localNotificationList removeAllObjects];
406
+ for (id obj in queuedLocal) {
407
+ if ([obj isKindOfClass:[NSDictionary class]]) {
408
+ [converter sendLocalNotificationEventByDictionary:(NSDictionary *)obj];
409
+ }
410
+ }
411
+ }
412
+ }
413
+
414
+ - (void)registerNotificationCenterObservers {
415
+ NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
416
+ [defaultCenter removeObserver:self];
417
+
418
+ [defaultCenter addObserver:self
419
+ selector:@selector(sendApnsNotificationEvent:)
420
+ name:J_APNS_NOTIFICATION_ARRIVED_EVENT
421
+ object:nil];
422
+ [defaultCenter addObserver:self
423
+ selector:@selector(sendApnsNotificationEvent:)
424
+ name:J_APNS_NOTIFICATION_OPENED_EVENT
425
+ object:nil];
426
+ [defaultCenter addObserver:self
427
+ selector:@selector(sendLocalNotificationEvent:)
428
+ name:J_LOCAL_NOTIFICATION_ARRIVED_EVENT
429
+ object:nil];
430
+ [defaultCenter addObserver:self
431
+ selector:@selector(sendLocalNotificationEvent:)
432
+ name:J_LOCAL_NOTIFICATION_OPENED_EVENT
433
+ object:nil];
434
+ [defaultCenter addObserver:self
435
+ selector:@selector(sendCustomNotificationEvent:)
436
+ name:J_CUSTOM_NOTIFICATION_EVENT
437
+ object:nil];
438
+ [defaultCenter addObserver:self
439
+ selector:@selector(sendConnectEvent:)
440
+ name:kJPFNetworkDidCloseNotification
441
+ object:nil];
442
+ [defaultCenter addObserver:self
443
+ selector:@selector(sendConnectEvent:)
444
+ name:kJPFNetworkFailedRegisterNotification
445
+ object:nil];
446
+ [defaultCenter addObserver:self
447
+ selector:@selector(sendConnectEvent:)
448
+ name:kJPFNetworkDidLoginNotification
449
+ object:nil];
450
+ }
451
+
452
+ - (instancetype)initAsSharedObserver {
453
+ #pragma clang diagnostic push
454
+ #pragma clang diagnostic ignored "-Wobjc-designated-initializers"
455
+ if ([self respondsToSelector:@selector(initWithDisabledObservation)]) {
456
+ self = [super initWithDisabledObservation];
457
+ } else {
458
+ self = [super init];
459
+ }
460
+ #pragma clang diagnostic pop
461
+ if (self) {
462
+ _hasListeners = NO;
463
+ [self registerNotificationCenterObservers];
464
+ }
465
+ return self;
466
+ }
467
+
468
+ - (instancetype)init {
469
+ #pragma clang diagnostic push
470
+ #pragma clang diagnostic ignored "-Wobjc-designated-initializers"
471
+ if ([self respondsToSelector:@selector(initWithDisabledObservation)]) {
472
+ self = [super initWithDisabledObservation];
473
+ } else {
474
+ self = [super init];
475
+ }
476
+ #pragma clang diagnostic pop
477
+ if (self) {
478
+ _hasListeners = NO;
479
+ [RCTJPushModule registerActiveModule:self];
480
+ [RCTJPushModule ensureSharedNativeObservers];
481
+
482
+ dispatch_async(dispatch_get_main_queue(), ^{
483
+ [RCTJPushModule flushPendingBridgeEvents];
484
+ });
485
+ }
486
+ return self;
487
+ }
488
+
489
+ - (void)dealloc {
490
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
491
+ }
492
+
493
+ RCT_EXPORT_METHOD(setDebugMode:(BOOL)enable) {
494
+ if (enable) {
495
+ [JPUSHService setDebugMode];
496
+ } else {
497
+ [JPUSHService setLogOFF];
498
+ }
499
+ }
500
+
501
+ - (void)setupOrRefreshJPushNativeState {
502
+ [RCTJPushModule ensureSharedNativeObservers];
503
+ if ([JPUSHNotificationManager shared].registerDelegate == nil) {
504
+ JPUSHRegisterEntity *entity = [[JPUSHRegisterEntity alloc] init];
505
+ entity.types = 0;
506
+ [JPUSHService registerForRemoteNotificationConfig:entity delegate:(id<JPUSHRegisterDelegate>)self];
507
+ }
508
+ if ([JPUSHNotificationManager shared].inAppMessageDelegate == nil) {
509
+ [JPUSHService setInAppMessageDelegate:(id<JPUSHInAppMessageDelegate>)self];
510
+ }
511
+ }
512
+
513
+ RCT_EXPORT_METHOD(initPush) {
514
+ [self setupOrRefreshJPushNativeState];
515
+ [RCTJPushModule flushQueuedNotifications];
516
+ }
517
+
518
+ RCT_EXPORT_METHOD(setupWithConfig:(NSDictionary *)params) {
519
+ [self setupOrRefreshJPushNativeState];
520
+ if (params[@"appKey"] && params[@"channel"] && params[@"production"] != nil) {
521
+ NSMutableDictionary *launchOptions = self.bridge.launchOptions
522
+ ? [NSMutableDictionary dictionaryWithDictionary:self.bridge.launchOptions]
523
+ : [NSMutableDictionary dictionary];
524
+ [JPUSHService setupWithOption:launchOptions
525
+ appKey:params[@"appKey"]
526
+ channel:params[@"channel"]
527
+ apsForProduction:[params[@"production"] boolValue]];
528
+ }
529
+ [RCTJPushModule flushQueuedNotifications];
530
+ }
531
+
532
+ RCT_EXPORT_METHOD(loadJS) {
533
+ [RCTJPushModule flushQueuedNotifications];
534
+ }
535
+
536
+ RCT_EXPORT_METHOD(getRegisterId:(RCTResponseSenderBlock)callback) {
537
+ [JPUSHService registrationIDCompletionHandler:^(int resCode, NSString *registrationID) {
538
+ (void)resCode;
539
+ NSDictionary *response = @{REGISTER_ID: registrationID ?: @""};
540
+ if (callback) {
541
+ callback(@[response]);
542
+ }
543
+ }];
544
+ }
545
+
546
+ RCT_EXPORT_METHOD(isNotificationEnabled:(RCTResponseSenderBlock)callback) {
547
+ [[JPUSHNotificationManager shared] getAuthorizationStatus:^(JPAuthorizationStatus status) {
548
+ BOOL enabled = (status > JPAuthorizationStatusDenied);
549
+ if (callback) {
550
+ callback(@[@(enabled)]);
551
+ }
552
+ }];
553
+ }
554
+
555
+ RCT_EXPORT_METHOD(addTags:(NSDictionary *)params) {
556
+ if ([params[TAGS] isKindOfClass:[NSArray class]]) {
557
+ NSArray *tags = [params[TAGS] copy];
558
+ if (tags != nil) {
559
+ NSSet *tagSet = [NSSet setWithArray:tags];
560
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
561
+ [JPUSHService addTags:tagSet completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
562
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), TAGS: [iTags allObjects] ?: @[]};
563
+ [self sendTagAliasEvent:data];
564
+ } seq:sequence];
565
+ }
566
+ }
567
+ }
568
+
569
+ RCT_EXPORT_METHOD(setTags:(NSDictionary *)params) {
570
+ if ([params[TAGS] isKindOfClass:[NSArray class]]) {
571
+ NSArray *tags = [params[TAGS] copy];
572
+ if (tags != nil) {
573
+ NSSet *tagSet = [NSSet setWithArray:tags];
574
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
575
+ [JPUSHService setTags:tagSet completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
576
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), TAGS: [iTags allObjects] ?: @[]};
577
+ [self sendTagAliasEvent:data];
578
+ } seq:sequence];
579
+ }
580
+ }
581
+ }
582
+
583
+ RCT_EXPORT_METHOD(deleteTags:(NSDictionary *)params) {
584
+ if ([params[TAGS] isKindOfClass:[NSArray class]]) {
585
+ NSArray *tags = [params[TAGS] copy];
586
+ if (tags != nil) {
587
+ NSSet *tagSet = [NSSet setWithArray:tags];
588
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
589
+ [JPUSHService deleteTags:tagSet completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
590
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), TAGS: [iTags allObjects] ?: @[]};
591
+ [self sendTagAliasEvent:data];
592
+ } seq:sequence];
593
+ }
594
+ }
595
+ }
596
+
597
+ RCT_EXPORT_METHOD(cleanTags:(NSDictionary *)params) {
598
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
599
+ [JPUSHService cleanTags:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
600
+ (void)iTags;
601
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq)};
602
+ [self sendTagAliasEvent:data];
603
+ } seq:sequence];
604
+ }
605
+
606
+ RCT_EXPORT_METHOD(getAllTags:(NSDictionary *)params) {
607
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
608
+ [JPUSHService getAllTags:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
609
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), TAGS: [iTags allObjects] ?: @[]};
610
+ [self sendTagAliasEvent:data];
611
+ } seq:sequence];
612
+ }
613
+
614
+ RCT_EXPORT_METHOD(validTag:(NSDictionary *)params) {
615
+ if (params[TAG]) {
616
+ NSString *tag = params[TAG];
617
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
618
+ [JPUSHService validTag:tag completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq, BOOL isBind) {
619
+ (void)iTags;
620
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), TAG_ENABLE: @(isBind), TAG: tag};
621
+ [self sendTagAliasEvent:data];
622
+ } seq:sequence];
623
+ }
624
+ }
625
+
626
+ RCT_EXPORT_METHOD(setAlias:(NSDictionary *)params) {
627
+ if (params[ALIAS]) {
628
+ NSString *alias = params[ALIAS];
629
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
630
+ [JPUSHService setAlias:alias completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
631
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), ALIAS: iAlias ?: @""};
632
+ [self sendTagAliasEvent:data];
633
+ } seq:sequence];
634
+ }
635
+ }
636
+
637
+ RCT_EXPORT_METHOD(deleteAlias:(NSDictionary *)params) {
638
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
639
+ [JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
640
+ (void)iAlias;
641
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq)};
642
+ [self sendTagAliasEvent:data];
643
+ } seq:sequence];
644
+ }
645
+
646
+ RCT_EXPORT_METHOD(getAlias:(NSDictionary *)params) {
647
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
648
+ [JPUSHService getAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
649
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), ALIAS: iAlias ?: @""};
650
+ [self sendTagAliasEvent:data];
651
+ } seq:sequence];
652
+ }
653
+
654
+ RCT_EXPORT_METHOD(setProperties:(NSDictionary *)params) {
655
+ if ([params[PROS] isKindOfClass:[NSDictionary class]]) {
656
+ NSDictionary *properties = params[PROS];
657
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
658
+ [JPUSHService setProperties:properties completion:^(NSInteger iResCode, NSDictionary *props, NSInteger seq) {
659
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), PROS: props ?: @{}};
660
+ [self sendTagAliasEvent:data];
661
+ [self sendPropertiesEvent:data];
662
+ } seq:sequence];
663
+ }
664
+ }
665
+
666
+ RCT_EXPORT_METHOD(deleteProperties:(NSDictionary *)params) {
667
+ if ([params[PROS] isKindOfClass:[NSDictionary class]]) {
668
+ NSDictionary *properties = params[PROS];
669
+ NSSet *set = [NSSet setWithArray:properties.allKeys];
670
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
671
+ [JPUSHService deleteProperties:set completion:^(NSInteger iResCode, NSDictionary *props, NSInteger seq) {
672
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), PROS: props ?: @{}};
673
+ [self sendTagAliasEvent:data];
674
+ [self sendPropertiesEvent:data];
675
+ } seq:sequence];
676
+ }
677
+ }
678
+
679
+ RCT_EXPORT_METHOD(cleanProperties:(NSDictionary *)params) {
680
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
681
+ [JPUSHService cleanProperties:^(NSInteger iResCode, NSDictionary *props, NSInteger seq) {
682
+ NSDictionary *data = @{CODE: @(iResCode), SEQUENCE: @(seq), PROS: props ?: @{}};
683
+ [self sendTagAliasEvent:data];
684
+ [self sendPropertiesEvent:data];
685
+ } seq:sequence];
686
+ }
687
+
688
+ RCT_EXPORT_METHOD(pageEnterTo:(NSString *)pageName) {
689
+ [JPUSHService pageEnterTo:pageName];
690
+ }
691
+
692
+ RCT_EXPORT_METHOD(pageLeave:(NSString *)pageName) {
693
+ [JPUSHService pageLeave:pageName];
694
+ }
695
+
696
+ RCT_EXPORT_METHOD(setCollectControl:(NSDictionary *)params) {
697
+ JPushCollectControl *control = [[JPushCollectControl alloc] init];
698
+ BOOL gps = YES;
699
+ BOOL cell = YES;
700
+ BOOL bssid = YES;
701
+ BOOL ssid = YES;
702
+ if ([params[@"gps"] isKindOfClass:[NSNumber class]]) {
703
+ gps = [params[@"gps"] boolValue];
704
+ }
705
+ if ([params[@"cell"] isKindOfClass:[NSNumber class]]) {
706
+ cell = [params[@"cell"] boolValue];
707
+ }
708
+ if ([params[@"bssid"] isKindOfClass:[NSNumber class]]) {
709
+ bssid = [params[@"bssid"] boolValue];
710
+ }
711
+ if ([params[@"ssid"] isKindOfClass:[NSNumber class]]) {
712
+ ssid = [params[@"ssid"] boolValue];
713
+ }
714
+ control.gps = gps;
715
+ control.cell = cell;
716
+ control.bssid = bssid;
717
+ control.ssid = ssid;
718
+ [JPUSHService setCollectControl:control];
719
+ }
720
+
721
+ RCT_EXPORT_METHOD(setSmartPushEnable:(BOOL)enable) {
722
+ [JPUSHService setSmartPushEnable:enable];
723
+ }
724
+
725
+ RCT_EXPORT_METHOD(setBackgroundEnable:(BOOL)enable) {
726
+ [JPUSHService setBackgroundEnable:enable];
727
+ }
728
+
729
+ - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center
730
+ willPresentNotification:(UNNotification *)notification
731
+ withCompletionHandler:(void (^)(NSInteger))completionHandler {
732
+ (void)center;
733
+ NSDictionary *userInfo = notification.request.content.userInfo ?: @{};
734
+ if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
735
+ [JPUSHService handleRemoteNotification:userInfo];
736
+ [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_ARRIVED_EVENT
737
+ object:userInfo
738
+ userInfo:userInfo];
739
+ } else {
740
+ [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_ARRIVED_EVENT
741
+ object:userInfo
742
+ userInfo:userInfo];
743
+ }
744
+ if (completionHandler != nil) {
745
+ completionHandler(UNNotificationPresentationOptionBadge |
746
+ UNNotificationPresentationOptionSound |
747
+ UNNotificationPresentationOptionAlert);
748
+ }
749
+ }
750
+
751
+ - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center
752
+ didReceiveNotificationResponse:(UNNotificationResponse *)response
753
+ withCompletionHandler:(void (^)(void))completionHandler {
754
+ (void)center;
755
+ NSDictionary *userInfo = response.notification.request.content.userInfo ?: @{};
756
+ if ([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
757
+ [JPUSHService handleRemoteNotification:userInfo];
758
+ [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_OPENED_EVENT
759
+ object:userInfo
760
+ userInfo:userInfo];
761
+ } else {
762
+ [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_OPENED_EVENT
763
+ object:userInfo
764
+ userInfo:userInfo];
765
+ }
766
+ if (completionHandler != nil) {
767
+ completionHandler();
768
+ }
769
+ }
770
+
771
+ - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center
772
+ openSettingsForNotification:(UNNotification *)notification {
773
+ (void)center;
774
+ (void)notification;
775
+ }
776
+
777
+ - (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
778
+ (void)status;
779
+ (void)info;
780
+ }
781
+
782
+ - (void)jPushInAppMessageDidShow:(JPushInAppMessage *)inAppMessage {
783
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onInAppMessageShow type=%@ msgId=%@",
784
+ INAPP_MESSAGE_SHOW, inAppMessage.mesageId ?: @""]];
785
+ NSDictionary *responseData = [self convertInappMsg:inAppMessage isShow:YES];
786
+ [RCTJPushModule emitEventWithName:INAPP_MESSAGE_EVENT payload:responseData];
787
+ }
788
+
789
+ - (void)jPushInAppMessageDidClick:(JPushInAppMessage *)inAppMessage {
790
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onInAppMessageClick type=%@ msgId=%@",
791
+ INAPP_MESSAGE_CLICK, inAppMessage.mesageId ?: @""]];
792
+ NSDictionary *responseData = [self convertInappMsg:inAppMessage isShow:NO];
793
+ [RCTJPushModule emitEventWithName:INAPP_MESSAGE_EVENT payload:responseData];
794
+ }
795
+
796
+ RCT_EXPORT_METHOD(setBadge:(NSDictionary *)params) {
797
+ if ([params[BADGE] isKindOfClass:[NSNumber class]]) {
798
+ NSInteger badgeValue = [params[BADGE] integerValue];
799
+ if (badgeValue >= 0) {
800
+ [JPUSHService setBadge:badgeValue];
801
+ }
802
+ }
803
+ if ([params[APP_BADGE] isKindOfClass:[NSNumber class]]) {
804
+ NSInteger appBadgeValue = [params[APP_BADGE] integerValue];
805
+ if (appBadgeValue >= 0) {
806
+ dispatch_async(dispatch_get_main_queue(), ^{
807
+ [UIApplication sharedApplication].applicationIconBadgeNumber = appBadgeValue;
808
+ });
809
+ }
810
+ }
811
+ }
812
+
813
+ - (void)sendPropertiesEvent:(NSDictionary *)data {
814
+ [RCTJPushModule emitEventWithName:PROPERTIES_EVENT payload:data];
815
+ }
816
+
817
+ RCT_EXPORT_METHOD(setMobileNumber:(NSDictionary *)params) {
818
+ if (params[MOBILE_NUMBER]) {
819
+ NSString *number = params[MOBILE_NUMBER];
820
+ NSInteger sequence = params[SEQUENCE] ? [params[SEQUENCE] integerValue] : -1;
821
+ [JPUSHService setMobileNumber:number completion:^(NSError *error) {
822
+ NSInteger code = error ? error.code : 0;
823
+ NSDictionary *data = @{CODE: @(code), SEQUENCE: @(sequence)};
824
+ [self sendMobileNumberEvent:data];
825
+ }];
826
+ }
827
+ }
828
+
829
+ RCT_EXPORT_METHOD(crashLogON:(NSDictionary *)params) {
830
+ (void)params;
831
+ [JPUSHService crashLogON];
832
+ }
833
+
834
+ RCT_EXPORT_METHOD(addNotification:(NSDictionary *)params) {
835
+ NSString *messageID = params[MESSAGE_ID] ?: @"";
836
+ JPushNotificationContent *content = [[JPushNotificationContent alloc] init];
837
+ NSString *notificationTitle = params[TITLE] ?: @"";
838
+ NSString *notificationContent = params[CONTENT] ?: @"";
839
+ content.title = notificationTitle;
840
+ content.body = notificationContent;
841
+ if (@available(iOS 15.0, *)) {
842
+ content.interruptionLevel = 1;
843
+ }
844
+ if (params[EXTRAS]) {
845
+ content.userInfo = @{
846
+ MESSAGE_ID: messageID,
847
+ TITLE: notificationTitle,
848
+ CONTENT: notificationContent,
849
+ EXTRAS: params[EXTRAS]
850
+ };
851
+ } else {
852
+ content.userInfo = @{
853
+ MESSAGE_ID: messageID,
854
+ TITLE: notificationTitle,
855
+ CONTENT: notificationContent
856
+ };
857
+ }
858
+ id broadcastTimeObj = params[BROADCASTTIME];
859
+ double rawSec = [broadcastTimeObj respondsToSelector:@selector(doubleValue)] ? [broadcastTimeObj doubleValue] : 0.0;
860
+ JPushNotificationTrigger *trigger = [[JPushNotificationTrigger alloc] init];
861
+ NSTimeInterval interval = 1.0;
862
+ if (rawSec > 0.0) {
863
+ interval = (rawSec > 1000000000000.0) ? (rawSec / 1000.0 - [[NSDate date] timeIntervalSince1970]) : rawSec;
864
+ }
865
+ trigger.timeInterval = MAX(1.0, interval);
866
+ JPushNotificationRequest *request = [[JPushNotificationRequest alloc] init];
867
+ request.requestIdentifier = messageID;
868
+ request.content = content;
869
+ request.trigger = trigger;
870
+ [JPUSHService addNotification:request];
871
+ }
872
+
873
+ RCT_EXPORT_METHOD(removeNotification:(NSDictionary *)params) {
874
+ NSString *requestIdentifier = params[MESSAGE_ID];
875
+ if ([requestIdentifier isKindOfClass:[NSString class]]) {
876
+ JPushNotificationIdentifier *pendingIdentifier = [[JPushNotificationIdentifier alloc] init];
877
+ pendingIdentifier.identifiers = @[requestIdentifier];
878
+ if (@available(iOS 10.0, *)) {
879
+ pendingIdentifier.delivered = NO;
880
+ }
881
+ [JPUSHService removeNotification:pendingIdentifier];
882
+
883
+ JPushNotificationIdentifier *deliveredIdentifier = [[JPushNotificationIdentifier alloc] init];
884
+ deliveredIdentifier.identifiers = @[requestIdentifier];
885
+ if (@available(iOS 10.0, *)) {
886
+ deliveredIdentifier.delivered = YES;
887
+ }
888
+ [JPUSHService removeNotification:deliveredIdentifier];
889
+ }
890
+ }
891
+
892
+ RCT_EXPORT_METHOD(clearLocalNotifications) {
893
+ [JPUSHService removeNotification:nil];
894
+ }
895
+
896
+ RCT_EXPORT_METHOD(removeGeofenceWithIdentifier:(NSDictionary *)params) {
897
+ if (params[GEO_FENCE_ID]) {
898
+ [JPUSHService removeGeofenceWithIdentifier:params[GEO_FENCE_ID]];
899
+ }
900
+ }
901
+
902
+ RCT_EXPORT_METHOD(setGeofeneceMaxCount:(NSDictionary *)params) {
903
+ if (params[GEO_FENCE_MAX_NUMBER]) {
904
+ [JPUSHService setGeofeneceMaxCount:[params[GEO_FENCE_MAX_NUMBER] integerValue]];
905
+ }
906
+ }
907
+
908
+ - (NSArray<NSString *> *)supportedEvents {
909
+ return @[
910
+ CONNECT_EVENT,
911
+ NOTIFICATION_EVENT,
912
+ CUSTOM_MESSAGE_EVENT,
913
+ LOCAL_NOTIFICATION_EVENT,
914
+ TAG_ALIAS_EVENT,
915
+ PROPERTIES_EVENT,
916
+ MOBILE_NUMBER_EVENT,
917
+ INAPP_MESSAGE_EVENT
918
+ ];
919
+ }
920
+
921
+ - (void)sendConnectEvent:(NSNotification *)data {
922
+ NSDictionary *responseData = [self convertConnect:data];
923
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onConnected state=%@",
924
+ [responseData[CONNECT_ENABLE] boolValue] ? @"true" : @"false"]];
925
+ [RCTJPushModule emitEventWithName:CONNECT_EVENT payload:responseData];
926
+ }
927
+
928
+ - (void)sendApnsNotificationEvent:(NSNotification *)data {
929
+ if (![RCTJPushModule hasReadyEventConsumer]) {
930
+ NSDictionary *objectData = [data.object isKindOfClass:[NSDictionary class]]
931
+ ? data.object
932
+ : ([data.userInfo isKindOfClass:[NSDictionary class]] ? data.userInfo : nil);
933
+ if (objectData != nil) {
934
+ if ([RCTJPushEventQueue sharedInstance]._notificationQueue == nil) {
935
+ [RCTJPushEventQueue sharedInstance]._notificationQueue = [NSMutableArray array];
936
+ }
937
+ NSMutableDictionary *queuedItem = [NSMutableDictionary dictionaryWithDictionary:objectData];
938
+ queuedItem[@"_j_InternalNotificationName"] = data.name ?: J_APNS_NOTIFICATION_OPENED_EVENT;
939
+ [[RCTJPushEventQueue sharedInstance]._notificationQueue addObject:[queuedItem copy]];
940
+ }
941
+ return;
942
+ }
943
+ NSDictionary *responseData = [self convertApnsMessage:data];
944
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onNotifyMessage type=%@ notificationType=remote msgId=%@",
945
+ responseData[NOTIFICATION_EVENT_TYPE] ?: @"",
946
+ responseData[MESSAGE_ID] ?: @""]];
947
+ [RCTJPushModule emitEventWithName:NOTIFICATION_EVENT payload:responseData];
948
+ if ([RCTJPushEventQueue sharedInstance]._notificationQueue.count > 0) {
949
+ [[RCTJPushEventQueue sharedInstance]._notificationQueue removeAllObjects];
950
+ }
951
+ }
952
+
953
+ - (void)sendApnsNotificationEventByDictionary:(NSDictionary *)data {
954
+ NSDictionary *responseData = [self convertApnsMessage:data];
955
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onNotifyMessage type=%@ notificationType=remote msgId=%@",
956
+ responseData[NOTIFICATION_EVENT_TYPE] ?: @"",
957
+ responseData[MESSAGE_ID] ?: @""]];
958
+ [RCTJPushModule emitEventWithName:NOTIFICATION_EVENT payload:responseData];
959
+ if ([RCTJPushEventQueue sharedInstance]._notificationQueue.count > 0) {
960
+ [[RCTJPushEventQueue sharedInstance]._notificationQueue removeAllObjects];
961
+ }
962
+ }
963
+
964
+ - (void)sendLocalNotificationEventByDictionary:(NSDictionary *)data {
965
+ NSDictionary *responseData = [self convertLocalMessage:data];
966
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onLocalNotification type=%@ notificationType=local msgId=%@",
967
+ responseData[NOTIFICATION_EVENT_TYPE] ?: @"",
968
+ responseData[MESSAGE_ID] ?: @""]];
969
+ [RCTJPushModule emitEventWithName:LOCAL_NOTIFICATION_EVENT payload:responseData];
970
+ if ([RCTJPushEventQueue sharedInstance]._localNotificationQueue.count > 0) {
971
+ [[RCTJPushEventQueue sharedInstance]._localNotificationQueue removeAllObjects];
972
+ }
973
+ }
974
+
975
+ - (void)sendCustomNotificationEvent:(NSNotification *)data {
976
+ NSDictionary *responseData = [self convertCustomMessage:data];
977
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onMessage type=customMessage msgId=%@",
978
+ responseData[MESSAGE_ID] ?: @""]];
979
+ [RCTJPushModule emitEventWithName:CUSTOM_MESSAGE_EVENT payload:responseData];
980
+ }
981
+
982
+ - (void)sendLocalNotificationEvent:(NSNotification *)data {
983
+ if (![RCTJPushModule hasReadyEventConsumer]) {
984
+ NSDictionary *objectData = [data.object isKindOfClass:[NSDictionary class]]
985
+ ? data.object
986
+ : ([data.userInfo isKindOfClass:[NSDictionary class]] ? data.userInfo : nil);
987
+ if (objectData != nil) {
988
+ if ([RCTJPushEventQueue sharedInstance]._localNotificationQueue == nil) {
989
+ [RCTJPushEventQueue sharedInstance]._localNotificationQueue = [NSMutableArray array];
990
+ }
991
+ NSMutableDictionary *queuedItem = [NSMutableDictionary dictionaryWithDictionary:objectData];
992
+ queuedItem[@"_j_InternalNotificationName"] = data.name ?: J_LOCAL_NOTIFICATION_OPENED_EVENT;
993
+ [[RCTJPushEventQueue sharedInstance]._localNotificationQueue addObject:[queuedItem copy]];
994
+ }
995
+ return;
996
+ }
997
+ NSDictionary *responseData = [self convertLocalMessage:data];
998
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onLocalNotification type=%@ notificationType=local msgId=%@",
999
+ responseData[NOTIFICATION_EVENT_TYPE] ?: @"",
1000
+ responseData[MESSAGE_ID] ?: @""]];
1001
+ [RCTJPushModule emitEventWithName:LOCAL_NOTIFICATION_EVENT payload:responseData];
1002
+ if ([RCTJPushEventQueue sharedInstance]._localNotificationQueue.count > 0) {
1003
+ [[RCTJPushEventQueue sharedInstance]._localNotificationQueue removeAllObjects];
1004
+ }
1005
+ }
1006
+
1007
+ - (void)sendTagAliasEvent:(NSDictionary *)data {
1008
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onTagAliasOperatorResult seq=%@ code=%@",
1009
+ data[SEQUENCE] ?: @0, data[CODE] ?: @0]];
1010
+ [RCTJPushModule emitEventWithName:TAG_ALIAS_EVENT payload:data];
1011
+ }
1012
+
1013
+ - (void)sendMobileNumberEvent:(NSDictionary *)data {
1014
+ [JCOREConfiguration logInfo:[NSString stringWithFormat:@"onMobileNumberOperatorResult seq=%@ code=%@",
1015
+ data[SEQUENCE] ?: @0, data[CODE] ?: @0]];
1016
+ [RCTJPushModule emitEventWithName:MOBILE_NUMBER_EVENT payload:data];
1017
+ }
1018
+
1019
+ - (NSDictionary *)convertConnect:(NSNotification *)data {
1020
+ NSNotificationName notificationName = data.name;
1021
+ BOOL isConnect = [notificationName isEqualToString:kJPFNetworkDidLoginNotification];
1022
+ return @{CONNECT_ENABLE: @(isConnect)};
1023
+ }
1024
+
1025
+ - (NSDictionary *)convertApnsMessage:(id)data {
1026
+ NSNotificationName notificationName = J_APNS_NOTIFICATION_ARRIVED_EVENT;
1027
+ NSDictionary *objectData = @{};
1028
+ if ([data isKindOfClass:[NSNotification class]]) {
1029
+ notificationName = [(NSNotification *)data name];
1030
+ if ([[(NSNotification *)data object] isKindOfClass:[NSDictionary class]]) {
1031
+ objectData = [(NSNotification *)data object];
1032
+ }
1033
+ } else if ([data isKindOfClass:[NSDictionary class]]) {
1034
+ NSDictionary *dictData = (NSDictionary *)data;
1035
+ NSString *internalName = [dictData[@"_j_InternalNotificationName"] isKindOfClass:[NSString class]]
1036
+ ? dictData[@"_j_InternalNotificationName"]
1037
+ : nil;
1038
+ notificationName = internalName.length > 0 ? internalName : J_APNS_NOTIFICATION_OPENED_EVENT;
1039
+ objectData = dictData;
1040
+ }
1041
+ NSString *notificationEventType = [notificationName isEqualToString:J_APNS_NOTIFICATION_OPENED_EVENT]
1042
+ ? NOTIFICATION_OPENED
1043
+ : NOTIFICATION_ARRIVED;
1044
+ id alertData = objectData[@"aps"][@"alert"];
1045
+ NSString *badge = objectData[@"aps"][@"badge"] ? [objectData[@"aps"][@"badge"] stringValue] : @"";
1046
+ NSString *sound = objectData[@"aps"][@"sound"] ?: @"";
1047
+
1048
+ NSString *title = @"";
1049
+ NSString *content = @"";
1050
+ if ([alertData isKindOfClass:[NSString class]]) {
1051
+ content = alertData;
1052
+ } else if ([alertData isKindOfClass:[NSDictionary class]]) {
1053
+ title = alertData[@"title"] ?: @"";
1054
+ content = alertData[@"body"] ?: @"";
1055
+ }
1056
+ NSMutableDictionary *copyData = [NSMutableDictionary dictionaryWithDictionary:objectData];
1057
+ [copyData removeObjectForKey:@"_j_business"];
1058
+ [copyData removeObjectForKey:@"_j_uid"];
1059
+ [copyData removeObjectForKey:@"_j_msgid"];
1060
+ [copyData removeObjectForKey:@"_j_InternalNotificationName"];
1061
+ [copyData removeObjectForKey:@"aps"];
1062
+
1063
+ NSMutableDictionary *extrasData = [NSMutableDictionary dictionary];
1064
+ for (NSString *key in copyData.allKeys) {
1065
+ id value = copyData[key];
1066
+ if (value != nil) {
1067
+ extrasData[key] = value;
1068
+ }
1069
+ }
1070
+ NSString *messageID = objectData[@"_j_msgid"] ? [objectData[@"_j_msgid"] description] : @"";
1071
+ if (extrasData.count > 0) {
1072
+ return @{
1073
+ MESSAGE_ID: messageID,
1074
+ TITLE: title,
1075
+ CONTENT: content,
1076
+ BADGE: badge,
1077
+ RING: sound,
1078
+ EXTRAS: extrasData,
1079
+ NOTIFICATION_EVENT_TYPE: notificationEventType
1080
+ };
1081
+ }
1082
+ return @{
1083
+ MESSAGE_ID: messageID,
1084
+ TITLE: title,
1085
+ CONTENT: content,
1086
+ BADGE: badge,
1087
+ RING: sound,
1088
+ NOTIFICATION_EVENT_TYPE: notificationEventType
1089
+ };
1090
+ }
1091
+
1092
+ - (NSDictionary *)convertLocalMessage:(id)data {
1093
+ NSNotificationName notificationName = J_LOCAL_NOTIFICATION_ARRIVED_EVENT;
1094
+ NSDictionary *objectData = @{};
1095
+ if ([data isKindOfClass:[NSNotification class]]) {
1096
+ notificationName = [(NSNotification *)data name];
1097
+ if ([[(NSNotification *)data object] isKindOfClass:[NSDictionary class]]) {
1098
+ objectData = [(NSNotification *)data object];
1099
+ }
1100
+ } else if ([data isKindOfClass:[NSDictionary class]]) {
1101
+ NSDictionary *dictData = (NSDictionary *)data;
1102
+ NSString *internalName = [dictData[@"_j_InternalNotificationName"] isKindOfClass:[NSString class]]
1103
+ ? dictData[@"_j_InternalNotificationName"]
1104
+ : nil;
1105
+ notificationName = internalName.length > 0 ? internalName : J_LOCAL_NOTIFICATION_OPENED_EVENT;
1106
+ NSMutableDictionary *cleanData = [NSMutableDictionary dictionaryWithDictionary:dictData];
1107
+ [cleanData removeObjectForKey:@"_j_InternalNotificationName"];
1108
+ objectData = [cleanData copy];
1109
+ }
1110
+ NSString *notificationEventType = [notificationName isEqualToString:J_LOCAL_NOTIFICATION_OPENED_EVENT]
1111
+ ? NOTIFICATION_OPENED
1112
+ : NOTIFICATION_ARRIVED;
1113
+ NSString *messageID = objectData[MESSAGE_ID] ?: @"";
1114
+ NSString *title = objectData[TITLE] ?: @"";
1115
+ NSString *content = objectData[CONTENT] ?: @"";
1116
+ if (objectData[EXTRAS]) {
1117
+ return @{
1118
+ MESSAGE_ID: messageID,
1119
+ TITLE: title,
1120
+ CONTENT: content,
1121
+ EXTRAS: objectData[EXTRAS],
1122
+ NOTIFICATION_EVENT_TYPE: notificationEventType
1123
+ };
1124
+ }
1125
+ return @{
1126
+ MESSAGE_ID: messageID,
1127
+ TITLE: title,
1128
+ CONTENT: content,
1129
+ NOTIFICATION_EVENT_TYPE: notificationEventType
1130
+ };
1131
+ }
1132
+
1133
+ - (NSDictionary *)convertCustomMessage:(NSNotification *)data {
1134
+ NSDictionary *objectData = [data.object isKindOfClass:[NSDictionary class]] ? data.object : @{};
1135
+ NSString *messageID = objectData[@"_j_msgid"] ? [objectData[@"_j_msgid"] description] : @"";
1136
+ NSString *title = objectData[@"title"] ?: @"";
1137
+ NSString *content = objectData[@"content"] ?: @"";
1138
+ if (objectData[@"extras"]) {
1139
+ return @{
1140
+ MESSAGE_ID: messageID,
1141
+ TITLE: title,
1142
+ CONTENT: content,
1143
+ EXTRAS: objectData[@"extras"]
1144
+ };
1145
+ }
1146
+ return @{
1147
+ MESSAGE_ID: messageID,
1148
+ TITLE: title,
1149
+ CONTENT: content
1150
+ };
1151
+ }
1152
+
1153
+ - (NSDictionary *)convertInappMsg:(JPushInAppMessage *)inAppMessage isShow:(BOOL)isShow {
1154
+ return @{
1155
+ @"mesageId": inAppMessage.mesageId ?: @"",
1156
+ @"title": inAppMessage.title ?: @"",
1157
+ @"content": inAppMessage.content ?: @"",
1158
+ @"target": inAppMessage.target ?: @[],
1159
+ @"clickAction": inAppMessage.clickAction ?: @"",
1160
+ @"extras": inAppMessage.extras ?: @{},
1161
+ INAPP_MESSAGE_EVENT_TYPE: isShow ? INAPP_MESSAGE_SHOW : INAPP_MESSAGE_CLICK
1162
+ };
1163
+ }
1164
+
1165
+ @end