react-native-fluxsens-syaxon 0.1.2 → 0.1.3
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/android/src/main/java/com/syaxonreactnativesdk/event/EventEmitter.kt +181 -161
- package/android/src/main/java/com/syaxonreactnativesdk/firebase/NotificationParser.kt +31 -26
- package/ios/Firebase/SyaxonFirebaseManager.m +2 -8
- package/ios/event/SyaxonEventEmitter.h +3 -0
- package/ios/event/SyaxonEventEmitter.m +28 -0
- package/lib/module/analytics/AnalyticsManager.js +139 -12
- package/lib/module/analytics/AnalyticsManager.js.map +1 -1
- package/lib/module/apis/apiService.js +4 -0
- package/lib/module/apis/apiService.js.map +1 -1
- package/lib/module/apis/endpoints.js +3 -1
- package/lib/module/apis/endpoints.js.map +1 -1
- package/lib/module/constants/EventTypes.js +4 -1
- package/lib/module/constants/EventTypes.js.map +1 -1
- package/lib/module/constants/StorageKeys.js +4 -1
- package/lib/module/constants/StorageKeys.js.map +1 -1
- package/lib/module/core/ConfigManager.js +61 -1
- package/lib/module/core/ConfigManager.js.map +1 -1
- package/lib/module/core/NetworkManager.js +0 -13
- package/lib/module/core/NetworkManager.js.map +1 -1
- package/lib/module/core/SDKManager.js +40 -3
- package/lib/module/core/SDKManager.js.map +1 -1
- package/lib/module/core/Syaxon.js +12 -0
- package/lib/module/core/Syaxon.js.map +1 -1
- package/lib/module/identity/UserManager.js +60 -0
- package/lib/module/identity/UserManager.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/analytics/AnalyticsManager.d.ts +15 -1
- package/lib/typescript/src/analytics/AnalyticsManager.d.ts.map +1 -1
- package/lib/typescript/src/apis/apiService.d.ts.map +1 -1
- package/lib/typescript/src/apis/endpoints.d.ts +2 -0
- package/lib/typescript/src/apis/endpoints.d.ts.map +1 -1
- package/lib/typescript/src/constants/EventTypes.d.ts +3 -0
- package/lib/typescript/src/constants/EventTypes.d.ts.map +1 -1
- package/lib/typescript/src/constants/StorageKeys.d.ts +3 -0
- package/lib/typescript/src/constants/StorageKeys.d.ts.map +1 -1
- package/lib/typescript/src/core/ConfigManager.d.ts +5 -0
- package/lib/typescript/src/core/ConfigManager.d.ts.map +1 -1
- package/lib/typescript/src/core/NetworkManager.d.ts.map +1 -1
- package/lib/typescript/src/core/SDKManager.d.ts +4 -0
- package/lib/typescript/src/core/SDKManager.d.ts.map +1 -1
- package/lib/typescript/src/core/Syaxon.d.ts +4 -0
- package/lib/typescript/src/core/Syaxon.d.ts.map +1 -1
- package/lib/typescript/src/identity/UserManager.d.ts +14 -0
- package/lib/typescript/src/identity/UserManager.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/SDKConfig.d.ts +1 -1
- package/lib/typescript/src/types/SDKConfig.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/analytics/AnalyticsManager.ts +174 -19
- package/src/apis/apiService.ts +14 -10
- package/src/apis/endpoints.ts +3 -1
- package/src/constants/EventTypes.ts +3 -0
- package/src/constants/StorageKeys.ts +8 -5
- package/src/core/ConfigManager.ts +75 -15
- package/src/core/NetworkManager.ts +0 -14
- package/src/core/SDKManager.ts +350 -310
- package/src/core/SessionManager.ts +125 -125
- package/src/core/Syaxon.ts +15 -0
- package/src/identity/UserManager.ts +77 -0
- package/src/index.tsx +1 -0
- package/src/types/SDKConfig.ts +1 -1
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
package com.syaxonreactnativesdk.event
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import com.facebook.react.bridge.Arguments
|
|
5
|
-
import com.facebook.react.bridge.
|
|
6
|
-
import com.facebook.react.bridge.
|
|
7
|
-
import com.facebook.react.
|
|
8
|
-
import com.facebook.react.
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
package com.syaxonreactnativesdk.event
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.facebook.react.common.LifecycleState
|
|
9
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
10
|
+
|
|
11
|
+
object EventEmitter {
|
|
11
12
|
|
|
12
13
|
private var reactContext: ReactApplicationContext? = null
|
|
14
|
+
private val pendingEvents = mutableListOf<Pair<String, WritableMap?>>()
|
|
15
|
+
|
|
16
|
+
fun initialize(context: ReactApplicationContext) {
|
|
17
|
+
reactContext = context
|
|
18
|
+
context.addLifecycleEventListener(object : LifecycleEventListener {
|
|
19
|
+
override fun onHostResume() {
|
|
20
|
+
flushPendingEvents()
|
|
21
|
+
}
|
|
22
|
+
override fun onHostPause() {}
|
|
23
|
+
override fun onHostDestroy() {}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private fun flushPendingEvents() {
|
|
28
|
+
val snapshot = pendingEvents.toList()
|
|
29
|
+
pendingEvents.clear()
|
|
30
|
+
snapshot.forEach { (event, params) ->
|
|
31
|
+
reactContext
|
|
32
|
+
?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
33
|
+
?.emit(event, params)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
13
36
|
|
|
14
|
-
fun
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fun isAppVisible(): Boolean {
|
|
25
|
-
return reactContext?.lifecycleState == LifecycleState.RESUMED
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
fun emit(
|
|
29
|
-
event: String,
|
|
37
|
+
fun currentActivity(): Activity? {
|
|
38
|
+
return reactContext?.currentActivity
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun isAppVisible(): Boolean {
|
|
42
|
+
return reactContext?.lifecycleState == LifecycleState.RESUMED
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun emit(
|
|
46
|
+
event: String,
|
|
30
47
|
params: WritableMap?
|
|
31
48
|
) {
|
|
49
|
+
if (reactContext?.lifecycleState != LifecycleState.RESUMED) {
|
|
50
|
+
pendingEvents.add(Pair(event, params))
|
|
51
|
+
return
|
|
52
|
+
}
|
|
32
53
|
|
|
33
54
|
reactContext
|
|
34
55
|
?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
35
56
|
?.emit(event, params)
|
|
36
|
-
|
|
37
57
|
}
|
|
38
58
|
|
|
39
59
|
fun emitToken(
|
|
@@ -51,107 +71,107 @@ object EventEmitter {
|
|
|
51
71
|
|
|
52
72
|
}
|
|
53
73
|
|
|
54
|
-
fun emitPushReceived(
|
|
55
|
-
campaignId: String?,
|
|
56
|
-
title: String?,
|
|
57
|
-
body: String?,
|
|
58
|
-
deepLink: String?,
|
|
59
|
-
imageUrl: String? = null,
|
|
60
|
-
clickAction: String? = null,
|
|
61
|
-
priority: String? = null,
|
|
62
|
-
badge: Int = 0,
|
|
63
|
-
sound: String? = null,
|
|
64
|
-
data: Map<String, String> = emptyMap()
|
|
65
|
-
) {
|
|
66
|
-
|
|
67
|
-
val map = createPushPayloadMap(
|
|
68
|
-
campaignId,
|
|
69
|
-
title,
|
|
70
|
-
body,
|
|
71
|
-
deepLink,
|
|
72
|
-
imageUrl,
|
|
73
|
-
clickAction,
|
|
74
|
-
priority,
|
|
75
|
-
badge,
|
|
76
|
-
sound,
|
|
77
|
-
data
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
emit(
|
|
81
|
-
EventConstants.PUSH_RECEIVED,
|
|
74
|
+
fun emitPushReceived(
|
|
75
|
+
campaignId: String?,
|
|
76
|
+
title: String?,
|
|
77
|
+
body: String?,
|
|
78
|
+
deepLink: String?,
|
|
79
|
+
imageUrl: String? = null,
|
|
80
|
+
clickAction: String? = null,
|
|
81
|
+
priority: String? = null,
|
|
82
|
+
badge: Int = 0,
|
|
83
|
+
sound: String? = null,
|
|
84
|
+
data: Map<String, String> = emptyMap()
|
|
85
|
+
) {
|
|
86
|
+
|
|
87
|
+
val map = createPushPayloadMap(
|
|
88
|
+
campaignId,
|
|
89
|
+
title,
|
|
90
|
+
body,
|
|
91
|
+
deepLink,
|
|
92
|
+
imageUrl,
|
|
93
|
+
clickAction,
|
|
94
|
+
priority,
|
|
95
|
+
badge,
|
|
96
|
+
sound,
|
|
97
|
+
data
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
emit(
|
|
101
|
+
EventConstants.PUSH_RECEIVED,
|
|
82
102
|
map
|
|
83
103
|
)
|
|
84
104
|
|
|
85
105
|
}
|
|
86
|
-
|
|
87
|
-
fun emitPushOpened(
|
|
88
|
-
campaignId: String?,
|
|
89
|
-
deepLink: String?,
|
|
90
|
-
title: String? = null,
|
|
91
|
-
body: String? = null,
|
|
92
|
-
imageUrl: String? = null,
|
|
93
|
-
clickAction: String? = null,
|
|
94
|
-
priority: String? = null,
|
|
95
|
-
badge: Int = 0,
|
|
96
|
-
sound: String? = null,
|
|
97
|
-
data: Map<String, String> = emptyMap()
|
|
98
|
-
) {
|
|
99
|
-
|
|
100
|
-
val map = createPushPayloadMap(
|
|
101
|
-
campaignId,
|
|
102
|
-
title,
|
|
103
|
-
body,
|
|
104
|
-
deepLink,
|
|
105
|
-
imageUrl,
|
|
106
|
-
clickAction,
|
|
107
|
-
priority,
|
|
108
|
-
badge,
|
|
109
|
-
sound,
|
|
110
|
-
data
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
emit(
|
|
114
|
-
EventConstants.PUSH_OPENED,
|
|
106
|
+
|
|
107
|
+
fun emitPushOpened(
|
|
108
|
+
campaignId: String?,
|
|
109
|
+
deepLink: String?,
|
|
110
|
+
title: String? = null,
|
|
111
|
+
body: String? = null,
|
|
112
|
+
imageUrl: String? = null,
|
|
113
|
+
clickAction: String? = null,
|
|
114
|
+
priority: String? = null,
|
|
115
|
+
badge: Int = 0,
|
|
116
|
+
sound: String? = null,
|
|
117
|
+
data: Map<String, String> = emptyMap()
|
|
118
|
+
) {
|
|
119
|
+
|
|
120
|
+
val map = createPushPayloadMap(
|
|
121
|
+
campaignId,
|
|
122
|
+
title,
|
|
123
|
+
body,
|
|
124
|
+
deepLink,
|
|
125
|
+
imageUrl,
|
|
126
|
+
clickAction,
|
|
127
|
+
priority,
|
|
128
|
+
badge,
|
|
129
|
+
sound,
|
|
130
|
+
data
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
emit(
|
|
134
|
+
EventConstants.PUSH_OPENED,
|
|
115
135
|
map
|
|
116
136
|
)
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
fun emitPushDismissed(
|
|
121
|
-
campaignId: String?,
|
|
122
|
-
title: String? = null,
|
|
123
|
-
body: String? = null,
|
|
124
|
-
deepLink: String? = null,
|
|
125
|
-
imageUrl: String? = null,
|
|
126
|
-
clickAction: String? = null,
|
|
127
|
-
priority: String? = null,
|
|
128
|
-
badge: Int = 0,
|
|
129
|
-
sound: String? = null,
|
|
130
|
-
data: Map<String, String> = emptyMap()
|
|
131
|
-
) {
|
|
132
|
-
|
|
133
|
-
val map = createPushPayloadMap(
|
|
134
|
-
campaignId,
|
|
135
|
-
title,
|
|
136
|
-
body,
|
|
137
|
-
deepLink,
|
|
138
|
-
imageUrl,
|
|
139
|
-
clickAction,
|
|
140
|
-
priority,
|
|
141
|
-
badge,
|
|
142
|
-
sound,
|
|
143
|
-
data
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
emit(
|
|
147
|
-
EventConstants.PUSH_DISMISSED,
|
|
148
|
-
map
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
fun emitPermissionChanged(
|
|
154
|
-
granted: Boolean
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
fun emitPushDismissed(
|
|
141
|
+
campaignId: String?,
|
|
142
|
+
title: String? = null,
|
|
143
|
+
body: String? = null,
|
|
144
|
+
deepLink: String? = null,
|
|
145
|
+
imageUrl: String? = null,
|
|
146
|
+
clickAction: String? = null,
|
|
147
|
+
priority: String? = null,
|
|
148
|
+
badge: Int = 0,
|
|
149
|
+
sound: String? = null,
|
|
150
|
+
data: Map<String, String> = emptyMap()
|
|
151
|
+
) {
|
|
152
|
+
|
|
153
|
+
val map = createPushPayloadMap(
|
|
154
|
+
campaignId,
|
|
155
|
+
title,
|
|
156
|
+
body,
|
|
157
|
+
deepLink,
|
|
158
|
+
imageUrl,
|
|
159
|
+
clickAction,
|
|
160
|
+
priority,
|
|
161
|
+
badge,
|
|
162
|
+
sound,
|
|
163
|
+
data
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
emit(
|
|
167
|
+
EventConstants.PUSH_DISMISSED,
|
|
168
|
+
map
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fun emitPermissionChanged(
|
|
174
|
+
granted: Boolean
|
|
155
175
|
) {
|
|
156
176
|
|
|
157
177
|
val map = Arguments.createMap()
|
|
@@ -162,42 +182,42 @@ object EventEmitter {
|
|
|
162
182
|
EventConstants.PERMISSION_CHANGED,
|
|
163
183
|
map
|
|
164
184
|
)
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private fun createPushPayloadMap(
|
|
169
|
-
campaignId: String?,
|
|
170
|
-
title: String?,
|
|
171
|
-
body: String?,
|
|
172
|
-
deepLink: String?,
|
|
173
|
-
imageUrl: String?,
|
|
174
|
-
clickAction: String?,
|
|
175
|
-
priority: String?,
|
|
176
|
-
badge: Int,
|
|
177
|
-
sound: String?,
|
|
178
|
-
data: Map<String, String>
|
|
179
|
-
): WritableMap {
|
|
180
|
-
|
|
181
|
-
val map = Arguments.createMap()
|
|
182
|
-
val dataMap = Arguments.createMap()
|
|
183
|
-
|
|
184
|
-
data.forEach { (key, value) ->
|
|
185
|
-
dataMap.putString(key, value)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
map.putString("title", title)
|
|
189
|
-
map.putString("message", body)
|
|
190
|
-
map.putString("body", body)
|
|
191
|
-
map.putString("imageUrl", imageUrl)
|
|
192
|
-
map.putString("campaignId", campaignId)
|
|
193
|
-
map.putString("deepLink", deepLink)
|
|
194
|
-
map.putString("clickAction", clickAction)
|
|
195
|
-
map.putString("priority", priority)
|
|
196
|
-
map.putInt("badge", badge)
|
|
197
|
-
map.putString("sound", sound)
|
|
198
|
-
map.putMap("data", dataMap)
|
|
199
|
-
|
|
200
|
-
return map
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private fun createPushPayloadMap(
|
|
189
|
+
campaignId: String?,
|
|
190
|
+
title: String?,
|
|
191
|
+
body: String?,
|
|
192
|
+
deepLink: String?,
|
|
193
|
+
imageUrl: String?,
|
|
194
|
+
clickAction: String?,
|
|
195
|
+
priority: String?,
|
|
196
|
+
badge: Int,
|
|
197
|
+
sound: String?,
|
|
198
|
+
data: Map<String, String>
|
|
199
|
+
): WritableMap {
|
|
200
|
+
|
|
201
|
+
val map = Arguments.createMap()
|
|
202
|
+
val dataMap = Arguments.createMap()
|
|
203
|
+
|
|
204
|
+
data.forEach { (key, value) ->
|
|
205
|
+
dataMap.putString(key, value)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
map.putString("title", title)
|
|
209
|
+
map.putString("message", body)
|
|
210
|
+
map.putString("body", body)
|
|
211
|
+
map.putString("imageUrl", imageUrl)
|
|
212
|
+
map.putString("campaignId", campaignId)
|
|
213
|
+
map.putString("deepLink", deepLink)
|
|
214
|
+
map.putString("clickAction", clickAction)
|
|
215
|
+
map.putString("priority", priority)
|
|
216
|
+
map.putInt("badge", badge)
|
|
217
|
+
map.putString("sound", sound)
|
|
218
|
+
map.putMap("data", dataMap)
|
|
219
|
+
|
|
220
|
+
return map
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
}
|
|
@@ -4,31 +4,36 @@ import com.google.firebase.messaging.RemoteMessage
|
|
|
4
4
|
|
|
5
5
|
object NotificationParser {
|
|
6
6
|
|
|
7
|
-
fun parse(remoteMessage: RemoteMessage): NotificationPayload {
|
|
8
|
-
|
|
9
|
-
val
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
campaignId = data["campaignId"],
|
|
23
|
-
deepLink = data["deepLink"],
|
|
24
|
-
clickAction = data["clickAction"] ?: data["click_action"],
|
|
25
|
-
priority = data["priority"],
|
|
26
|
-
sound = data["sound"],
|
|
27
|
-
badge = data["badge"]?.toIntOrNull() ?: 0,
|
|
28
|
-
data = data.toMutableMap()
|
|
29
|
-
)
|
|
30
|
-
return payload
|
|
31
|
-
|
|
7
|
+
fun parse(remoteMessage: RemoteMessage): NotificationPayload {
|
|
8
|
+
val notification = remoteMessage.notification
|
|
9
|
+
val data = remoteMessage.data
|
|
10
|
+
return NotificationPayload(
|
|
11
|
+
title = notification?.title ?: data["title"] ?: data["notificationTitle"],
|
|
12
|
+
body = notification?.body ?: data["body"] ?: data["message"] ?: data["notificationBody"],
|
|
13
|
+
imageUrl = notification?.imageUrl?.toString() ?: data["imageUrl"] ?: data["image"],
|
|
14
|
+
campaignId = data["campaignId"],
|
|
15
|
+
deepLink = data["deepLink"],
|
|
16
|
+
clickAction = data["clickAction"] ?: data["click_action"],
|
|
17
|
+
priority = data["priority"],
|
|
18
|
+
sound = data["sound"],
|
|
19
|
+
badge = data["badge"]?.toIntOrNull() ?: 0,
|
|
20
|
+
data = data.toMutableMap()
|
|
21
|
+
)
|
|
32
22
|
}
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
fun parseFromData(data: Map<String, String>): NotificationPayload {
|
|
25
|
+
return NotificationPayload(
|
|
26
|
+
title = data["title"] ?: data["notificationTitle"],
|
|
27
|
+
body = data["body"] ?: data["message"] ?: data["notificationBody"],
|
|
28
|
+
imageUrl = data["imageUrl"] ?: data["image"],
|
|
29
|
+
campaignId = data["campaignId"],
|
|
30
|
+
deepLink = data["deepLink"],
|
|
31
|
+
clickAction = data["clickAction"] ?: data["click_action"],
|
|
32
|
+
priority = data["priority"],
|
|
33
|
+
sound = data["sound"],
|
|
34
|
+
badge = data["badge"]?.toIntOrNull() ?: 0,
|
|
35
|
+
data = data.toMutableMap()
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -155,14 +155,8 @@ didReceiveRegistrationToken:(nullable NSString *)fcmToken
|
|
|
155
155
|
|
|
156
156
|
[SyaxonNotificationEventStore saveOpened:payload];
|
|
157
157
|
|
|
158
|
-
[
|
|
159
|
-
|
|
160
|
-
body:payloadDictionary];
|
|
161
|
-
|
|
162
|
-
// TODO:
|
|
163
|
-
// AnalyticsManager.trackPushOpened(payload)
|
|
164
|
-
// Open Deep Link
|
|
165
|
-
// Handle In-App Actions
|
|
158
|
+
[SyaxonEventEmitter bufferEventWithName:SyaxonPushOpenedEvent
|
|
159
|
+
body:payloadDictionary];
|
|
166
160
|
}
|
|
167
161
|
|
|
168
162
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
RCT_EXPORT_MODULE();
|
|
6
6
|
|
|
7
7
|
static SyaxonEventEmitter *sharedEmitter = nil;
|
|
8
|
+
static NSMutableArray<NSDictionary *> *pendingEvents = nil;
|
|
8
9
|
|
|
9
10
|
+ (instancetype)shared
|
|
10
11
|
{
|
|
@@ -17,11 +18,38 @@ static SyaxonEventEmitter *sharedEmitter = nil;
|
|
|
17
18
|
|
|
18
19
|
if (self) {
|
|
19
20
|
sharedEmitter = self;
|
|
21
|
+
[self flushPendingEvents];
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
return self;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
+ (void)bufferEventWithName:(NSString *)name body:(NSDictionary *)body
|
|
28
|
+
{
|
|
29
|
+
if (sharedEmitter) {
|
|
30
|
+
[sharedEmitter sendEventWithName:name body:body];
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!pendingEvents) {
|
|
35
|
+
pendingEvents = [NSMutableArray array];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[pendingEvents addObject:@{ @"name": name, @"body": body ?: @{} }];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (void)flushPendingEvents
|
|
42
|
+
{
|
|
43
|
+
if (!pendingEvents || pendingEvents.count == 0) return;
|
|
44
|
+
|
|
45
|
+
NSArray *snapshot = [pendingEvents copy];
|
|
46
|
+
[pendingEvents removeAllObjects];
|
|
47
|
+
|
|
48
|
+
for (NSDictionary *event in snapshot) {
|
|
49
|
+
[self sendEventWithName:event[@"name"] body:event[@"body"]];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
- (NSArray<NSString *> *)supportedEvents
|
|
26
54
|
{
|
|
27
55
|
return @[
|