react-native-fluxsens-syaxon 0.1.2 → 0.1.4
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/SyaxonDeviceInfoModule.kt +12 -12
- 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/SyaxonDeviceInfo.mm +12 -12
- package/ios/event/SyaxonEventEmitter.h +3 -0
- package/ios/event/SyaxonEventEmitter.m +28 -0
- package/lib/module/analytics/AnalyticsManager.js +144 -14
- package/lib/module/analytics/AnalyticsManager.js.map +1 -1
- package/lib/module/analytics/StandardEventBuilder.js +4 -2
- package/lib/module/analytics/StandardEventBuilder.js.map +1 -1
- package/lib/module/apis/EventBatchApi.js +7 -1
- package/lib/module/apis/EventBatchApi.js.map +1 -1
- package/lib/module/apis/apiService.js +15 -5
- 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 +20 -17
- 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 +34 -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/module/metadata/MetadataManager.js +2 -2
- package/lib/module/metadata/MetadataManager.js.map +1 -1
- package/lib/module/queue/QueueManager.js +20 -15
- package/lib/module/queue/QueueManager.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/analytics/StandardEventBuilder.d.ts.map +1 -1
- package/lib/typescript/src/apis/EventBatchApi.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 +20 -17
- 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 +4 -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/models/Event.d.ts +4 -1
- package/lib/typescript/src/models/Event.d.ts.map +1 -1
- package/lib/typescript/src/models/SDKAttributes.d.ts +17 -17
- package/lib/typescript/src/models/SDKAttributes.d.ts.map +1 -1
- package/lib/typescript/src/queue/QueueManager.d.ts +2 -1
- package/lib/typescript/src/queue/QueueManager.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeSyaxonDeviceInfo.d.ts +12 -12
- package/lib/typescript/src/specs/NativeSyaxonDeviceInfo.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 +179 -21
- package/src/analytics/StandardEventBuilder.ts +4 -2
- package/src/apis/EventBatchApi.ts +9 -1
- package/src/apis/apiService.ts +31 -18
- package/src/apis/endpoints.ts +3 -1
- package/src/constants/EventTypes.ts +20 -17
- package/src/constants/StorageKeys.ts +11 -8
- package/src/core/ConfigManager.ts +40 -5
- 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/metadata/MetadataManager.ts +2 -2
- package/src/models/Event.ts +18 -15
- package/src/models/SDKAttributes.ts +18 -18
- package/src/queue/QueueManager.ts +21 -16
- package/src/specs/NativeSyaxonDeviceInfo.ts +13 -13
- package/src/types/SDKConfig.ts +1 -1
|
@@ -48,18 +48,18 @@ class SyaxonDeviceInfoModule(
|
|
|
48
48
|
|
|
49
49
|
val map = Arguments.createMap()
|
|
50
50
|
|
|
51
|
-
map.putString("
|
|
52
|
-
map.putString("
|
|
53
|
-
map.putString("
|
|
54
|
-
map.putString("
|
|
55
|
-
map.putString("
|
|
56
|
-
map.putString("
|
|
57
|
-
map.putString("
|
|
58
|
-
map.putString("
|
|
59
|
-
map.putString("
|
|
60
|
-
map.putString("
|
|
61
|
-
map.putString("
|
|
62
|
-
map.putString("
|
|
51
|
+
map.putString("device-id", deviceId)
|
|
52
|
+
map.putString("device-model", Build.MODEL)
|
|
53
|
+
map.putString("manufacturer", Build.MANUFACTURER)
|
|
54
|
+
map.putString("os", "Android")
|
|
55
|
+
map.putString("os-version", Build.VERSION.RELEASE)
|
|
56
|
+
map.putString("app-name", appName)
|
|
57
|
+
map.putString("package-name", packageName)
|
|
58
|
+
map.putString("app-version", versionName)
|
|
59
|
+
map.putString("build-number", buildNumber)
|
|
60
|
+
map.putString("country", locale.country)
|
|
61
|
+
map.putString("language", locale.language)
|
|
62
|
+
map.putString("timezone", java.util.TimeZone.getDefault().id)
|
|
63
63
|
|
|
64
64
|
promise.resolve(map)
|
|
65
65
|
|
|
@@ -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
|
package/ios/SyaxonDeviceInfo.mm
CHANGED
|
@@ -42,18 +42,18 @@ RCT_EXPORT_MODULE(SyaxonDeviceInfo)
|
|
|
42
42
|
#pragma clang diagnostic pop
|
|
43
43
|
|
|
44
44
|
resolve(@{
|
|
45
|
-
@"
|
|
46
|
-
@"
|
|
47
|
-
@"
|
|
48
|
-
@"
|
|
49
|
-
@"
|
|
50
|
-
@"
|
|
51
|
-
@"
|
|
52
|
-
@"
|
|
53
|
-
@"
|
|
54
|
-
@"
|
|
55
|
-
@"
|
|
56
|
-
@"
|
|
45
|
+
@"device-id": deviceId,
|
|
46
|
+
@"device-model": deviceModel,
|
|
47
|
+
@"manufacturer": @"Apple",
|
|
48
|
+
@"os": device.systemName ?: @"iOS",
|
|
49
|
+
@"os-version": device.systemVersion ?: @"",
|
|
50
|
+
@"app-name": info[@"CFBundleDisplayName"] ?: info[@"CFBundleName"] ?: @"",
|
|
51
|
+
@"package-name": [[NSBundle mainBundle] bundleIdentifier] ?: @"",
|
|
52
|
+
@"app-version": info[@"CFBundleShortVersionString"] ?: @"",
|
|
53
|
+
@"build-number": info[@"CFBundleVersion"] ?: @"",
|
|
54
|
+
@"country": [locale objectForKey:NSLocaleCountryCode] ?: @"",
|
|
55
|
+
@"language": [locale objectForKey:NSLocaleLanguageCode] ?: @"",
|
|
56
|
+
@"timezone": NSTimeZone.localTimeZone.name ?: @""
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -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 @[
|