@developer_tribe/react-native-comnyx 0.12.5 → 0.12.6
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/comnyx/ComnyxModule.kt +39 -11
- package/android/src/main/java/com/comnyx/Logger.kt +69 -0
- package/android/src/main/java/com/comnyx/src/messaging/ComnyxMessaging.kt +5 -0
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FCM.kt +7 -4
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +7 -2
- package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +13 -14
- package/lib/commonjs/NativeComnyx.js.map +1 -1
- package/lib/commonjs/hooks/useListenNativeTokenForDebug.js +12 -0
- package/lib/commonjs/hooks/useListenNativeTokenForDebug.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/notifications/initializeNotifications.js +13 -5
- package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
- package/lib/commonjs/store/store.js +6 -0
- package/lib/commonjs/store/store.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/NativeComnyx.js.map +1 -1
- package/lib/module/hooks/useListenNativeTokenForDebug.js +9 -0
- package/lib/module/hooks/useListenNativeTokenForDebug.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/notifications/initializeNotifications.js +13 -5
- package/lib/module/notifications/initializeNotifications.js.map +1 -1
- package/lib/module/store/store.js +6 -0
- package/lib/module/store/store.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/NativeComnyx.d.ts +4 -1
- package/lib/typescript/src/NativeComnyx.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts +2 -0
- package/lib/typescript/src/hooks/useListenNativeTokenForDebug.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/notifications/initializeNotifications.d.ts +1 -0
- package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
- package/lib/typescript/src/store/store.d.ts +2 -0
- package/lib/typescript/src/store/store.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/NativeComnyx.ts +4 -1
- package/src/hooks/useListenNativeTokenForDebug.ts +6 -0
- package/src/index.ts +1 -0
- package/src/notifications/initializeNotifications.ts +19 -7
- package/src/store/store.ts +6 -0
- package/src/version.ts +1 -1
|
@@ -8,10 +8,12 @@ import com.facebook.react.bridge.ReactContext
|
|
|
8
8
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
9
|
import com.facebook.react.bridge.ReactMethod
|
|
10
10
|
import com.facebook.react.bridge.WritableMap
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
11
12
|
import com.facebook.react.module.annotations.ReactModule
|
|
12
13
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
13
14
|
import com.facebook.react.modules.core.PermissionListener
|
|
14
15
|
import android.util.Log
|
|
16
|
+
import com.comnyx.Logger
|
|
15
17
|
import android.Manifest
|
|
16
18
|
import android.content.pm.PackageManager
|
|
17
19
|
import android.os.Build
|
|
@@ -35,6 +37,7 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
35
37
|
private val PERMISSION_REQUEST_CODE = 100
|
|
36
38
|
|
|
37
39
|
init {
|
|
40
|
+
Logger.v("ComnyxModule init", NAME)
|
|
38
41
|
comnyxMessaging = ComnyxMessaging(reactContext)
|
|
39
42
|
__self = this
|
|
40
43
|
}
|
|
@@ -44,6 +47,7 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
private fun sendEvent(reactContext: ReactContext, eventName: String, params: Any?) {
|
|
50
|
+
Logger.v("sendEvent($eventName) params=${params != null}", NAME)
|
|
47
51
|
reactContext
|
|
48
52
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
49
53
|
.emit(eventName, params)
|
|
@@ -58,13 +62,25 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
@ReactMethod
|
|
61
|
-
fun initialize(promise: Promise) {
|
|
65
|
+
fun initialize(options: ReadableMap?, promise: Promise) {
|
|
66
|
+
Logger.v("initialize called", NAME)
|
|
67
|
+
try {
|
|
68
|
+
if (options != null && options.hasKey("logLevel") && !options.isNull("logLevel")) {
|
|
69
|
+
val level = options.getString("logLevel")
|
|
70
|
+
Logger.setLevel(level)
|
|
71
|
+
Logger.i("Log level set to ${level}", NAME)
|
|
72
|
+
}
|
|
73
|
+
} catch (e: Exception) {
|
|
74
|
+
Logger.w("Failed to parse initialize options: ${e.message}", NAME)
|
|
75
|
+
}
|
|
62
76
|
comnyxMessaging.initialize( { token ->
|
|
77
|
+
Logger.i("Messaging initialized, token received", NAME)
|
|
63
78
|
val params = Arguments.createMap()
|
|
64
79
|
params.putString("token", token)
|
|
65
80
|
sendEvent(reactApplicationContext, "TOKEN_INIT", params)
|
|
66
81
|
val activity = reactApplicationContext.currentActivity
|
|
67
82
|
if(activity?.intent !== null){
|
|
83
|
+
Logger.v("Processing initial activity intent", NAME)
|
|
68
84
|
ComnyxModule.handleNewIntent(activity.intent)
|
|
69
85
|
}
|
|
70
86
|
|
|
@@ -73,9 +89,11 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
73
89
|
result.putString("country", java.util.Locale.getDefault().country)
|
|
74
90
|
result.putString("timezone", java.util.TimeZone.getDefault().id)
|
|
75
91
|
result.putString("language", java.util.Locale.getDefault().language)
|
|
92
|
+
Logger.i("Initialization successful", NAME)
|
|
76
93
|
promise.resolve(result)
|
|
77
94
|
},
|
|
78
95
|
{ exception ->
|
|
96
|
+
Logger.e("Initialization failed: ${exception.message}", NAME, exception)
|
|
79
97
|
promise.reject("TOKEN_FAILED", exception.message, exception)
|
|
80
98
|
}
|
|
81
99
|
)
|
|
@@ -83,7 +101,7 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
83
101
|
|
|
84
102
|
@ReactMethod
|
|
85
103
|
fun checkOptIn(promise: Promise) {
|
|
86
|
-
|
|
104
|
+
Logger.v("checkOptIn called", NAME)
|
|
87
105
|
try {
|
|
88
106
|
// Check system notification settings
|
|
89
107
|
val notificationManager = reactApplicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
@@ -113,21 +131,22 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
113
131
|
if (areNotificationsEnabled) "granted" else "blocked"
|
|
114
132
|
}
|
|
115
133
|
|
|
116
|
-
|
|
134
|
+
Logger.i("Notification status: $permissionStatus", NAME)
|
|
117
135
|
promise.resolve(permissionStatus)
|
|
118
136
|
} catch (e: Exception) {
|
|
119
|
-
|
|
137
|
+
Logger.e("Error checking opt-in status: ${e.message}", NAME, e)
|
|
120
138
|
promise.reject("ERROR_CHECK_OPT_IN", e.message, e)
|
|
121
139
|
}
|
|
122
140
|
}
|
|
123
141
|
|
|
124
142
|
@ReactMethod
|
|
125
143
|
fun optIn(promise: Promise) {
|
|
126
|
-
|
|
144
|
+
Logger.v("optIn called", NAME)
|
|
127
145
|
try {
|
|
128
146
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
129
147
|
val activity = currentActivity
|
|
130
148
|
if (activity == null) {
|
|
149
|
+
Logger.w("Activity is not available during opt-in", NAME)
|
|
131
150
|
throw Exception("Activity is not available")
|
|
132
151
|
}
|
|
133
152
|
|
|
@@ -136,12 +155,13 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
136
155
|
Manifest.permission.POST_NOTIFICATIONS
|
|
137
156
|
) == PackageManager.PERMISSION_GRANTED
|
|
138
157
|
) {
|
|
139
|
-
|
|
158
|
+
Logger.i("Permission already granted", NAME)
|
|
140
159
|
promise.resolve("granted")
|
|
141
160
|
return
|
|
142
161
|
}
|
|
143
162
|
|
|
144
163
|
pendingPromise = promise
|
|
164
|
+
Logger.v("Requesting POST_NOTIFICATIONS permission", NAME)
|
|
145
165
|
ActivityCompat.requestPermissions(
|
|
146
166
|
activity,
|
|
147
167
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
|
@@ -151,16 +171,18 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
151
171
|
// On Android 12 and below, check system settings
|
|
152
172
|
val notificationManager = reactApplicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
153
173
|
val areNotificationsEnabled = notificationManager.areNotificationsEnabled()
|
|
154
|
-
|
|
174
|
+
val status = if (areNotificationsEnabled) "granted" else "blocked"
|
|
175
|
+
Logger.i("Pre-Android 13 notification setting: $status", NAME)
|
|
176
|
+
promise.resolve(status)
|
|
155
177
|
}
|
|
156
178
|
} catch (e: Exception) {
|
|
157
|
-
|
|
179
|
+
Logger.e("Error requesting opt-in permission: ${e.message}", NAME, e)
|
|
158
180
|
promise.reject("ERROR_OPT_IN", e.message, e)
|
|
159
181
|
}
|
|
160
182
|
}
|
|
161
183
|
|
|
162
184
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray): Boolean {
|
|
163
|
-
|
|
185
|
+
Logger.v("onRequestPermissionsResult requestCode=$requestCode", NAME)
|
|
164
186
|
if (requestCode == PERMISSION_REQUEST_CODE) {
|
|
165
187
|
val status = when {
|
|
166
188
|
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED -> "granted"
|
|
@@ -169,7 +191,7 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
169
191
|
} == true -> "blocked"
|
|
170
192
|
else -> "denied"
|
|
171
193
|
}
|
|
172
|
-
|
|
194
|
+
Logger.i("Permission status: $status", NAME)
|
|
173
195
|
|
|
174
196
|
pendingPromise?.resolve(status)
|
|
175
197
|
pendingPromise = null
|
|
@@ -179,10 +201,12 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
179
201
|
}
|
|
180
202
|
|
|
181
203
|
fun onNotificationShown(params: WritableMap) {
|
|
204
|
+
Logger.v("onNotificationShown event forwarded", NAME)
|
|
182
205
|
sendEvent(reactApplicationContext, "NOTIFICATION_RECEIVED", params)
|
|
183
206
|
}
|
|
184
207
|
|
|
185
208
|
fun onNotificationClicked(params: WritableMap) {
|
|
209
|
+
Logger.v("onNotificationClicked event forwarded", NAME)
|
|
186
210
|
sendEvent(reactApplicationContext, "NOTIFICATION_CLICKED", params)
|
|
187
211
|
}
|
|
188
212
|
|
|
@@ -207,9 +231,10 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
207
231
|
}
|
|
208
232
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
209
233
|
reactApplicationContext.startActivity(intent)
|
|
234
|
+
Logger.i("Opened notification settings", NAME)
|
|
210
235
|
promise.resolve(true)
|
|
211
236
|
} catch (e: Exception) {
|
|
212
|
-
|
|
237
|
+
Logger.e("Failed to open settings: ${e.message}", NAME, e)
|
|
213
238
|
promise.reject("SETTINGS_ERROR", "Could not open notification settings", e)
|
|
214
239
|
}
|
|
215
240
|
|
|
@@ -226,6 +251,7 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
226
251
|
return
|
|
227
252
|
}
|
|
228
253
|
intent?.let {
|
|
254
|
+
Logger.v("handleNewIntent type=$type", NAME)
|
|
229
255
|
val params = Arguments.createMap()
|
|
230
256
|
params.putString("comnyx_type", type ?: "")
|
|
231
257
|
params.putString("title", it.getStringExtra("title") ?: "")
|
|
@@ -300,9 +326,11 @@ class ComnyxModule(reactContext: ReactApplicationContext) :
|
|
|
300
326
|
params.putMap("raw", rawMap)
|
|
301
327
|
|
|
302
328
|
if(type == "notification_clicked"){
|
|
329
|
+
Logger.i("Forwarding click event to JS", NAME)
|
|
303
330
|
__self?.onNotificationClicked(params)
|
|
304
331
|
} else {
|
|
305
332
|
//TODO: remove this
|
|
333
|
+
Logger.i("Forwarding shown event to JS", NAME)
|
|
306
334
|
__self?.onNotificationShown(params)
|
|
307
335
|
}
|
|
308
336
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
package com.comnyx
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
|
|
5
|
+
object Logger {
|
|
6
|
+
private const val DEFAULT_TAG = "Comnyx"
|
|
7
|
+
|
|
8
|
+
enum class Level(val priority: Int) {
|
|
9
|
+
VERBOSE(Log.VERBOSE),
|
|
10
|
+
DEBUG(Log.DEBUG),
|
|
11
|
+
INFO(Log.INFO),
|
|
12
|
+
WARN(Log.WARN),
|
|
13
|
+
ERROR(Log.ERROR),
|
|
14
|
+
NONE(Int.MAX_VALUE)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Volatile
|
|
18
|
+
private var currentLevel: Level = Level.INFO
|
|
19
|
+
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun setLevel(level: String?) {
|
|
22
|
+
val normalized = level?.trim()?.lowercase()
|
|
23
|
+
currentLevel = when (normalized) {
|
|
24
|
+
"v", "verbose" -> Level.VERBOSE
|
|
25
|
+
"d", "debug" -> Level.DEBUG
|
|
26
|
+
"i", "info" -> Level.INFO
|
|
27
|
+
"w", "warn", "warning" -> Level.WARN
|
|
28
|
+
"e", "error" -> Level.ERROR
|
|
29
|
+
"none", "silent", "off" -> Level.NONE
|
|
30
|
+
else -> Level.INFO
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private fun shouldLog(level: Level): Boolean {
|
|
35
|
+
return level.priority >= currentLevel.priority && currentLevel != Level.NONE
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@JvmStatic
|
|
39
|
+
fun v(message: String, tag: String = DEFAULT_TAG, throwable: Throwable? = null) {
|
|
40
|
+
if (!shouldLog(Level.VERBOSE)) return
|
|
41
|
+
if (throwable != null) Log.v(tag, message, throwable) else Log.v(tag, message)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@JvmStatic
|
|
45
|
+
fun d(message: String, tag: String = DEFAULT_TAG, throwable: Throwable? = null) {
|
|
46
|
+
if (!shouldLog(Level.DEBUG)) return
|
|
47
|
+
if (throwable != null) Log.d(tag, message, throwable) else Log.d(tag, message)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@JvmStatic
|
|
51
|
+
fun i(message: String, tag: String = DEFAULT_TAG, throwable: Throwable? = null) {
|
|
52
|
+
if (!shouldLog(Level.INFO)) return
|
|
53
|
+
if (throwable != null) Log.i(tag, message, throwable) else Log.i(tag, message)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@JvmStatic
|
|
57
|
+
fun w(message: String, tag: String = DEFAULT_TAG, throwable: Throwable? = null) {
|
|
58
|
+
if (!shouldLog(Level.WARN)) return
|
|
59
|
+
if (throwable != null) Log.w(tag, message, throwable) else Log.w(tag, message)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@JvmStatic
|
|
63
|
+
fun e(message: String, tag: String = DEFAULT_TAG, throwable: Throwable? = null) {
|
|
64
|
+
if (!shouldLog(Level.ERROR)) return
|
|
65
|
+
if (throwable != null) Log.e(tag, message, throwable) else Log.e(tag, message)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
@@ -2,22 +2,27 @@ package com.comnyx.messaging
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
import android.util.Log
|
|
5
|
+
import com.comnyx.Logger
|
|
5
6
|
|
|
6
7
|
class ComnyxMessaging(reactApplicationContext: ReactApplicationContext) {
|
|
7
8
|
private val fcm : FCM?
|
|
8
9
|
private val reactApplicationContext : ReactApplicationContext
|
|
9
10
|
|
|
10
11
|
init {
|
|
12
|
+
Logger.v("ComnyxMessaging init", "Comnyx")
|
|
11
13
|
this.reactApplicationContext = reactApplicationContext
|
|
12
14
|
this.fcm = FCM(reactApplicationContext)
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
public fun initialize(onSuccess: (token: String) -> Unit, onError: (exception: Exception) -> Unit) {
|
|
18
|
+
Logger.v("ComnyxMessaging.initialize called", "Comnyx")
|
|
16
19
|
this.fcm!!.getToken(
|
|
17
20
|
onSuccess = { token ->
|
|
21
|
+
Logger.i("FCM token obtained", "Comnyx")
|
|
18
22
|
onSuccess(token)
|
|
19
23
|
},
|
|
20
24
|
onError = { exception ->
|
|
25
|
+
Logger.e("Failed to obtain FCM token: ${exception.message}", "Comnyx", exception)
|
|
21
26
|
onError(exception)
|
|
22
27
|
}
|
|
23
28
|
)
|
|
@@ -4,6 +4,7 @@ import android.content.Context
|
|
|
4
4
|
import android.util.Log
|
|
5
5
|
import com.google.firebase.FirebaseApp
|
|
6
6
|
import com.google.firebase.messaging.FirebaseMessaging
|
|
7
|
+
import com.comnyx.Logger
|
|
7
8
|
|
|
8
9
|
class FCM(private val context: Context) {
|
|
9
10
|
companion object {
|
|
@@ -12,25 +13,27 @@ class FCM(private val context: Context) {
|
|
|
12
13
|
|
|
13
14
|
init {
|
|
14
15
|
try {
|
|
16
|
+
Logger.v("FCM init", TAG)
|
|
15
17
|
if (FirebaseApp.getApps(context).isEmpty()) {
|
|
16
18
|
FirebaseApp.initializeApp(context)
|
|
17
|
-
|
|
19
|
+
Logger.i("Firebase initialized successfully", TAG)
|
|
18
20
|
}
|
|
19
21
|
} catch (e: Exception) {
|
|
20
|
-
|
|
22
|
+
Logger.e("Failed to initialize Firebase: ${e.message}", TAG, e)
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
fun getToken(onSuccess: (String) -> Unit, onError: (Exception) -> Unit) {
|
|
27
|
+
Logger.v("Requesting FCM token", TAG)
|
|
25
28
|
FirebaseMessaging.getInstance().token
|
|
26
29
|
.addOnCompleteListener { task ->
|
|
27
30
|
if (task.isSuccessful) {
|
|
28
31
|
val token = task.result
|
|
29
|
-
|
|
32
|
+
Logger.i("FCM token fetched", TAG)
|
|
30
33
|
onSuccess(token)
|
|
31
34
|
} else {
|
|
32
35
|
val exception = task.exception ?: Exception("Unknown error occurred")
|
|
33
|
-
|
|
36
|
+
Logger.e("Failed to get FCM token: ${exception.message}", TAG, exception)
|
|
34
37
|
onError(exception)
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -4,6 +4,7 @@ import android.util.Log
|
|
|
4
4
|
import com.comnyx.ComnyxModule
|
|
5
5
|
import com.google.firebase.messaging.FirebaseMessagingService
|
|
6
6
|
import com.google.firebase.messaging.RemoteMessage
|
|
7
|
+
import com.comnyx.Logger
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
open class ComnyxFirebaseMessagingService : FirebaseMessagingService() {
|
|
@@ -13,16 +14,19 @@ open class ComnyxFirebaseMessagingService : FirebaseMessagingService() {
|
|
|
13
14
|
|
|
14
15
|
override fun onCreate() {
|
|
15
16
|
super.onCreate()
|
|
17
|
+
Logger.v("FirebaseMessagingService onCreate", "Comnyx")
|
|
16
18
|
notificationsHelper = NotificationsHelper(this)
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
20
22
|
//https://stackoverflow.com/a/40083727
|
|
21
23
|
super.onMessageReceived(remoteMessage)
|
|
24
|
+
Logger.v("onMessageReceived from=${remoteMessage.from}", "Comnyx")
|
|
22
25
|
if(isRemoteMessageFromComnyx(remoteMessage)) {
|
|
26
|
+
Logger.i("Message identified as Comnyx", "Comnyx")
|
|
23
27
|
notificationsHelper.showNotification(remoteMessage)
|
|
24
28
|
}else{
|
|
25
|
-
|
|
29
|
+
Logger.w("Message is not from Comnyx", "Comnyx")
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -31,12 +35,13 @@ open class ComnyxFirebaseMessagingService : FirebaseMessagingService() {
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
override fun onNewToken(token: String) {
|
|
38
|
+
Logger.v("onNewToken received", "Comnyx")
|
|
34
39
|
sendRegistrationToServer(token)
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
private fun sendRegistrationToServer(token: String) {
|
|
38
43
|
//TODO: send token to server
|
|
39
|
-
|
|
44
|
+
Logger.i("sendRegistrationTokenToServer called", "Comnyx")
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
|
package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt
CHANGED
|
@@ -13,6 +13,7 @@ import com.comnyx.ComnyxModule
|
|
|
13
13
|
import com.facebook.react.bridge.Arguments
|
|
14
14
|
import com.facebook.react.bridge.WritableMap
|
|
15
15
|
import com.google.firebase.messaging.RemoteMessage
|
|
16
|
+
import com.comnyx.Logger
|
|
16
17
|
|
|
17
18
|
class NotificationsHelper(private val context: Context) {
|
|
18
19
|
|
|
@@ -23,13 +24,13 @@ class NotificationsHelper(private val context: Context) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
init {
|
|
26
|
-
|
|
27
|
+
Logger.v("Initializing NotificationsHelper", TAG)
|
|
27
28
|
createNotificationChannel()
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
private fun createNotificationChannel() {
|
|
31
32
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
32
|
-
|
|
33
|
+
Logger.v("Creating notification channel for Android O and above", TAG)
|
|
33
34
|
val name = "Standard Notifications"
|
|
34
35
|
val description = "Regular notifications channel"
|
|
35
36
|
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
|
@@ -44,14 +45,14 @@ class NotificationsHelper(private val context: Context) {
|
|
|
44
45
|
enableVibration(true)
|
|
45
46
|
}
|
|
46
47
|
notificationManager.createNotificationChannel(channel)
|
|
47
|
-
|
|
48
|
+
Logger.i("Notification channel created successfully", TAG)
|
|
48
49
|
} else {
|
|
49
|
-
|
|
50
|
+
Logger.v("Skipping notification channel creation - running on Android N or below", TAG)
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
fun showNotification(remoteMessage: RemoteMessage) {
|
|
54
|
-
|
|
55
|
+
Logger.v("Showing notification - title=${remoteMessage.notification?.title}", TAG)
|
|
55
56
|
val title: String = remoteMessage.data["title"] ?: remoteMessage.notification?.title ?: ""
|
|
56
57
|
val message: String = remoteMessage.data["body"] ?: remoteMessage.notification?.body ?: ""
|
|
57
58
|
val subtitle: String = remoteMessage.data["subtitle"] ?: remoteMessage.notification?.bodyLocalizationKey ?: ""
|
|
@@ -65,9 +66,7 @@ class NotificationsHelper(private val context: Context) {
|
|
|
65
66
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
66
67
|
|
|
67
68
|
// Add all data as extras
|
|
68
|
-
data?.let {
|
|
69
|
-
Log.d(TAG, "Adding extra data to notification: $it")
|
|
70
|
-
}
|
|
69
|
+
data?.let { Logger.v("Adding extra data to notification: $it", TAG) }
|
|
71
70
|
data?.forEach { (key, value) ->
|
|
72
71
|
intent.putExtra(key, value)
|
|
73
72
|
}
|
|
@@ -126,15 +125,15 @@ class NotificationsHelper(private val context: Context) {
|
|
|
126
125
|
val iconResourceId = context.resources.getIdentifier("com.google.firebase.messaging.default_notification_icon", "drawable", context.packageName)
|
|
127
126
|
if (iconResourceId != 0) {
|
|
128
127
|
builder.setSmallIcon(iconResourceId)
|
|
129
|
-
|
|
128
|
+
Logger.v("Using Firebase default notification icon", TAG)
|
|
130
129
|
} else {
|
|
131
130
|
try {
|
|
132
131
|
val appInfo = context.packageManager.getApplicationInfo(context.packageName, 0)
|
|
133
132
|
builder.setSmallIcon(appInfo.icon)
|
|
134
|
-
|
|
133
|
+
Logger.v("Firebase default notification icon not found, using app icon", TAG)
|
|
135
134
|
} catch (e: Exception) {
|
|
136
135
|
builder.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
137
|
-
|
|
136
|
+
Logger.v("Using system default icon as final fallback", TAG)
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
|
|
@@ -145,7 +144,7 @@ class NotificationsHelper(private val context: Context) {
|
|
|
145
144
|
|
|
146
145
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
147
146
|
notificationManager.notify(NOTIFICATION_ID, builder.build())
|
|
148
|
-
|
|
147
|
+
Logger.i("Notification displayed successfully", TAG)
|
|
149
148
|
|
|
150
149
|
val writableMap: WritableMap = Arguments.createMap()
|
|
151
150
|
writableMap.putString("comnyx_type", "notification_shown")
|
|
@@ -203,9 +202,9 @@ class NotificationsHelper(private val context: Context) {
|
|
|
203
202
|
}
|
|
204
203
|
writableMap.putMap("raw", rawMap)
|
|
205
204
|
ComnyxModule.__self?.onNotificationShown(writableMap)
|
|
206
|
-
|
|
205
|
+
Logger.i("Notification event sent to JS", TAG)
|
|
207
206
|
} catch (e: Exception) {
|
|
208
|
-
|
|
207
|
+
Logger.e("Error showing notification: ${e.message}", TAG, e)
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NotificationPermissionStatus","exports","nativeComnyx","NativeModules","Comnyx"],"sourceRoot":"../../src","sources":["NativeComnyx.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAA6C,IAEjCC,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,0BAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NotificationPermissionStatus","exports","nativeComnyx","NativeModules","Comnyx"],"sourceRoot":"../../src","sources":["NativeComnyx.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAA6C,IAEjCC,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,0BAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA;AAsBjC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAGC,0BAAa,CAACC,MAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useListenNativeTokenForDebug = useListenNativeTokenForDebug;
|
|
7
|
+
var _store = require("../store/store.js");
|
|
8
|
+
//NOTE: It's temporary fo
|
|
9
|
+
function useListenNativeTokenForDebug() {
|
|
10
|
+
return _store.useAppStore.subscribe(state => state.token);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=useListenNativeTokenForDebug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_store","require","useListenNativeTokenForDebug","useAppStore","subscribe","state","token"],"sourceRoot":"../../../src","sources":["hooks/useListenNativeTokenForDebug.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA;AACO,SAASC,4BAA4BA,CAAA,EAAG;EAC7C,OAAOC,kBAAW,CAACC,SAAS,CAAEC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC;AACtD","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -39,6 +39,13 @@ Object.defineProperty(exports, "useIsComnyxRegistered", {
|
|
|
39
39
|
return _useIsComnyxRegistered.useIsComnyxRegistered;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "useListenNativeTokenForDebug", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _useListenNativeTokenForDebug.useListenNativeTokenForDebug;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _useListenNativeTokenForDebug = require("./hooks/useListenNativeTokenForDebug.js");
|
|
42
49
|
var _index = require("./register/index.js");
|
|
43
50
|
var _index2 = require("./support/index.js");
|
|
44
51
|
var _index3 = require("./notifications/index.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_useListenNativeTokenForDebug","require","_index","_index2","_index3","_NativeComnyx","_collectData","_useIsComnyxRegistered"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,6BAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AAGA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA","ignoreList":[]}
|
|
@@ -49,11 +49,12 @@ function changePermissionStatus(status) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
async function initializeNativeNotifications() {
|
|
52
|
+
async function initializeNativeNotifications(options) {
|
|
53
53
|
const state = _store.useAppStore.getState();
|
|
54
54
|
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
55
55
|
globalSubscriptions.subscriptionsForNotification = [_index.ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
56
56
|
if (_reactNative.Platform.OS === 'ios') {
|
|
57
|
+
_store.useAppStore.getState().setToken(data.token);
|
|
57
58
|
_Accumulator.accumulator.add({
|
|
58
59
|
apnsToken: data.token
|
|
59
60
|
});
|
|
@@ -66,7 +67,11 @@ async function initializeNativeNotifications() {
|
|
|
66
67
|
//TODO: logger
|
|
67
68
|
console.error('TOKEN_FAILED', data);
|
|
68
69
|
})];
|
|
69
|
-
|
|
70
|
+
var sendOptions = options;
|
|
71
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
72
|
+
sendOptions = undefined;
|
|
73
|
+
}
|
|
74
|
+
return await _NativeComnyx.nativeComnyx.initialize(sendOptions).then(res => {
|
|
70
75
|
state.setNotificationInitialized(true);
|
|
71
76
|
if (res.success) {
|
|
72
77
|
_Accumulator.accumulator.add({
|
|
@@ -87,6 +92,9 @@ async function initializeNotifications(params = {}) {
|
|
|
87
92
|
if (!(0, _api.isLoginCalled)()) {
|
|
88
93
|
throw new Error('Please call login first');
|
|
89
94
|
}
|
|
95
|
+
const options = {
|
|
96
|
+
logLevel: params.logLevel ?? 'warn'
|
|
97
|
+
};
|
|
90
98
|
let result = false;
|
|
91
99
|
if (globalSubscriptions.subscriptionsForNotification.length > 0) {
|
|
92
100
|
globalSubscriptions.subscriptionsForNotification.forEach(subscription => subscription.remove());
|
|
@@ -97,7 +105,7 @@ async function initializeNotifications(params = {}) {
|
|
|
97
105
|
const permissionResult = await _index.ComnyxNotifications.checkOptIn();
|
|
98
106
|
changePermissionStatus(permissionResult);
|
|
99
107
|
if (permissionResult === _NativeComnyx.NotificationPermissionStatus.GRANTED) {
|
|
100
|
-
result = await initializeNativeNotifications();
|
|
108
|
+
result = await initializeNativeNotifications(options);
|
|
101
109
|
} else {
|
|
102
110
|
if (params.showOptIn) {
|
|
103
111
|
if (permissionResult === _NativeComnyx.NotificationPermissionStatus.DENIED) {
|
|
@@ -121,14 +129,14 @@ async function initializeNotifications(params = {}) {
|
|
|
121
129
|
if (permissionGivenInForeground === _NativeComnyx.NotificationPermissionStatus.GRANTED) {
|
|
122
130
|
const state = _store.useAppStore.getState();
|
|
123
131
|
if (!state.notificationInitialized) {
|
|
124
|
-
await initializeNativeNotifications();
|
|
132
|
+
await initializeNativeNotifications(options);
|
|
125
133
|
}
|
|
126
134
|
} else {
|
|
127
135
|
if (params.showOptInOnForeground) {
|
|
128
136
|
_index.ComnyxNotifications.optIn().then(async permissionResultInner => {
|
|
129
137
|
changePermissionStatus(permissionResultInner);
|
|
130
138
|
if (permissionResultInner === _NativeComnyx.NotificationPermissionStatus.GRANTED) {
|
|
131
|
-
await initializeNativeNotifications();
|
|
139
|
+
await initializeNativeNotifications(options);
|
|
132
140
|
} else if (permissionResultInner === _NativeComnyx.NotificationPermissionStatus.BLOCKED) {
|
|
133
141
|
if (params.linkToSettings) {
|
|
134
142
|
showAlertDialog();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_index","_NativeComnyx","_store","_api","_useLocalize","_Accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","isAlertShowing","showAlertDialog","Platform","OS","Alert","alert","localize","text","style","onPress","ComnyxNotifications","linkToSettings","changePermissionStatus","status","state","useAppStore","getState","NotificationPermissionStatus","GRANTED","permissionGiven","setPermissionGiven","accumulator","add","allow_notifications","initializeNativeNotifications","addEventListener","data","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_index","_NativeComnyx","_store","_api","_useLocalize","_Accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","isAlertShowing","showAlertDialog","Platform","OS","Alert","alert","localize","text","style","onPress","ComnyxNotifications","linkToSettings","changePermissionStatus","status","state","useAppStore","getState","NotificationPermissionStatus","GRANTED","permissionGiven","setPermissionGiven","accumulator","add","allow_notifications","initializeNativeNotifications","options","addEventListener","data","setToken","token","apnsToken","fcmToken","console","error","sendOptions","undefined","nativeComnyx","initialize","then","res","setNotificationInitialized","success","platform","country","language","timezone","initializeNotifications","params","isInitCalled","Error","isLoginCalled","logLevel","result","length","forEach","subscription","remove","permissionResult","checkOptIn","showOptIn","DENIED","permissionResultAfterDenied","optIn","BLOCKED","AppState","nextAppState","permissionGivenInForeground","notificationInitialized","showOptInOnForeground","permissionResultInner"],"sourceRoot":"../../../src","sources":["notifications/initializeNotifications.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;A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ACF;UACF,CAAC,CAAC;QACJ;MACF;IACF;EACF,CACF,CAAC;EAED,OAAOmD,MAAM;AACf","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_middleware","require","_shallow","_traditional","_asyncStorage","_interopRequireDefault","e","__esModule","default","storeCreator","set","get","baseWidth","baseHeight","initialized","customer","data","language","theme","fake","themes","firstMessage","formSubmitted","setData","cb","newData","setFirstMessage","message","setCustomer","createCustomerResponse","name","setLanguage","setTheme","setFake","setThemes","updateBaseDimensions","setForm","form","permissionGiven","setPermissionGiven","notificationInitialized","setNotificationInitialized","toastMessage","setToastMessage","registered","setRegistered","exports","useAppStore","createWithEqualityFn","persist","storage","createJSONStorage","AsyncStorage","skipHydration","partialize","state","shallow"],"sourceRoot":"../../../src","sources":["store/store.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqE,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;
|
|
1
|
+
{"version":3,"names":["_middleware","require","_shallow","_traditional","_asyncStorage","_interopRequireDefault","e","__esModule","default","storeCreator","set","get","baseWidth","baseHeight","initialized","customer","data","language","theme","fake","themes","firstMessage","formSubmitted","setData","cb","newData","setFirstMessage","message","setCustomer","createCustomerResponse","name","setLanguage","setTheme","setFake","setThemes","updateBaseDimensions","setForm","form","permissionGiven","setPermissionGiven","notificationInitialized","setNotificationInitialized","toastMessage","setToastMessage","token","setToken","registered","setRegistered","exports","useAppStore","createWithEqualityFn","persist","storage","createJSONStorage","AsyncStorage","skipHydration","partialize","state","shallow"],"sourceRoot":"../../../src","sources":["store/store.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IA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C,6BAAiB,EAAC,MAAMC,qBAAY,CAAC;EAC9CC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAGC,KAAK,KAAM;IACtB1C,QAAQ,EAAE0C,KAAK,CAAC1C,QAAQ;IACxBO,aAAa,EAAEmC,KAAK,CAACnC,aAAa;IAClCgB,eAAe,EAAEmB,KAAK,CAACnB;EACzB,CAAC;AACH,CAAC,CAAC,EACFoB,gBACF,CAAC","ignoreList":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NotificationPermissionStatus","nativeComnyx","Comnyx"],"sourceRoot":"../../src","sources":["NativeComnyx.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,WAAYC,4BAA4B,0BAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA;
|
|
1
|
+
{"version":3,"names":["NativeModules","NotificationPermissionStatus","nativeComnyx","Comnyx"],"sourceRoot":"../../src","sources":["NativeComnyx.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,WAAYC,4BAA4B,0BAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA;AAsBxC,OAAO,MAAMC,YAAY,GAAGF,aAAa,CAACG,MAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useAppStore } from "../store/store.js";
|
|
4
|
+
|
|
5
|
+
//NOTE: It's temporary fo
|
|
6
|
+
export function useListenNativeTokenForDebug() {
|
|
7
|
+
return useAppStore.subscribe(state => state.token);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=useListenNativeTokenForDebug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAppStore","useListenNativeTokenForDebug","subscribe","state","token"],"sourceRoot":"../../../src","sources":["hooks/useListenNativeTokenForDebug.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,mBAAgB;;AAE5C;AACA,OAAO,SAASC,4BAA4BA,CAAA,EAAG;EAC7C,OAAOD,WAAW,CAACE,SAAS,CAAEC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC;AACtD","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
export { useListenNativeTokenForDebug } from "./hooks/useListenNativeTokenForDebug.js";
|
|
3
4
|
export { Comnyx } from "./register/index.js";
|
|
4
5
|
export { ComnyxSupport } from "./support/index.js";
|
|
5
6
|
export { ComnyxNotifications } from "./notifications/index.js";
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Comnyx","ComnyxSupport","ComnyxNotifications","NotificationPermissionStatus","registerOneSignalForComnyx","useIsComnyxRegistered"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["useListenNativeTokenForDebug","Comnyx","ComnyxSupport","ComnyxNotifications","NotificationPermissionStatus","registerOneSignalForComnyx","useIsComnyxRegistered"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,4BAA4B,QAAQ,yCAAsC;AAEnF,SAASC,MAAM,QAAQ,qBAAY;AACnC,SAASC,aAAa,QAAQ,oBAAW;AACzC,SAASC,mBAAmB,QAAQ,0BAAiB;AACrD;AACA,SAASC,4BAA4B,QAAQ,mBAAgB;;AAE7D;AACA,SAASC,0BAA0B,QAAQ,2BAAwB;AACnE,SAASC,qBAAqB,QAAQ,kCAA+B","ignoreList":[]}
|
|
@@ -45,11 +45,12 @@ function changePermissionStatus(status) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
async function initializeNativeNotifications() {
|
|
48
|
+
async function initializeNativeNotifications(options) {
|
|
49
49
|
const state = useAppStore.getState();
|
|
50
50
|
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
51
51
|
globalSubscriptions.subscriptionsForNotification = [ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
52
52
|
if (Platform.OS === 'ios') {
|
|
53
|
+
useAppStore.getState().setToken(data.token);
|
|
53
54
|
accumulator.add({
|
|
54
55
|
apnsToken: data.token
|
|
55
56
|
});
|
|
@@ -62,7 +63,11 @@ async function initializeNativeNotifications() {
|
|
|
62
63
|
//TODO: logger
|
|
63
64
|
console.error('TOKEN_FAILED', data);
|
|
64
65
|
})];
|
|
65
|
-
|
|
66
|
+
var sendOptions = options;
|
|
67
|
+
if (Platform.OS === 'ios') {
|
|
68
|
+
sendOptions = undefined;
|
|
69
|
+
}
|
|
70
|
+
return await nativeComnyx.initialize(sendOptions).then(res => {
|
|
66
71
|
state.setNotificationInitialized(true);
|
|
67
72
|
if (res.success) {
|
|
68
73
|
accumulator.add({
|
|
@@ -83,6 +88,9 @@ export async function initializeNotifications(params = {}) {
|
|
|
83
88
|
if (!isLoginCalled()) {
|
|
84
89
|
throw new Error('Please call login first');
|
|
85
90
|
}
|
|
91
|
+
const options = {
|
|
92
|
+
logLevel: params.logLevel ?? 'warn'
|
|
93
|
+
};
|
|
86
94
|
let result = false;
|
|
87
95
|
if (globalSubscriptions.subscriptionsForNotification.length > 0) {
|
|
88
96
|
globalSubscriptions.subscriptionsForNotification.forEach(subscription => subscription.remove());
|
|
@@ -93,7 +101,7 @@ export async function initializeNotifications(params = {}) {
|
|
|
93
101
|
const permissionResult = await ComnyxNotifications.checkOptIn();
|
|
94
102
|
changePermissionStatus(permissionResult);
|
|
95
103
|
if (permissionResult === NotificationPermissionStatus.GRANTED) {
|
|
96
|
-
result = await initializeNativeNotifications();
|
|
104
|
+
result = await initializeNativeNotifications(options);
|
|
97
105
|
} else {
|
|
98
106
|
if (params.showOptIn) {
|
|
99
107
|
if (permissionResult === NotificationPermissionStatus.DENIED) {
|
|
@@ -117,14 +125,14 @@ export async function initializeNotifications(params = {}) {
|
|
|
117
125
|
if (permissionGivenInForeground === NotificationPermissionStatus.GRANTED) {
|
|
118
126
|
const state = useAppStore.getState();
|
|
119
127
|
if (!state.notificationInitialized) {
|
|
120
|
-
await initializeNativeNotifications();
|
|
128
|
+
await initializeNativeNotifications(options);
|
|
121
129
|
}
|
|
122
130
|
} else {
|
|
123
131
|
if (params.showOptInOnForeground) {
|
|
124
132
|
ComnyxNotifications.optIn().then(async permissionResultInner => {
|
|
125
133
|
changePermissionStatus(permissionResultInner);
|
|
126
134
|
if (permissionResultInner === NotificationPermissionStatus.GRANTED) {
|
|
127
|
-
await initializeNativeNotifications();
|
|
135
|
+
await initializeNativeNotifications(options);
|
|
128
136
|
} else if (permissionResultInner === NotificationPermissionStatus.BLOCKED) {
|
|
129
137
|
if (params.linkToSettings) {
|
|
130
138
|
showAlertDialog();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Alert","AppState","Platform","ComnyxNotifications","nativeComnyx","NotificationPermissionStatus","useAppStore","isInitCalled","isLoginCalled","localize","accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","isAlertShowing","showAlertDialog","OS","alert","text","style","onPress","linkToSettings","changePermissionStatus","status","state","getState","GRANTED","permissionGiven","setPermissionGiven","add","allow_notifications","initializeNativeNotifications","addEventListener","data","
|
|
1
|
+
{"version":3,"names":["Alert","AppState","Platform","ComnyxNotifications","nativeComnyx","NotificationPermissionStatus","useAppStore","isInitCalled","isLoginCalled","localize","accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","isAlertShowing","showAlertDialog","OS","alert","text","style","onPress","linkToSettings","changePermissionStatus","status","state","getState","GRANTED","permissionGiven","setPermissionGiven","add","allow_notifications","initializeNativeNotifications","options","addEventListener","data","setToken","token","apnsToken","fcmToken","console","error","sendOptions","undefined","initialize","then","res","setNotificationInitialized","success","platform","country","language","timezone","initializeNotifications","params","Error","logLevel","result","length","forEach","subscription","remove","permissionResult","checkOptIn","showOptIn","DENIED","permissionResultAfterDenied","optIn","BLOCKED","nextAppState","permissionGivenInForeground","notificationInitialized","showOptInOnForeground","permissionResultInner"],"sourceRoot":"../../../src","sources":["notifications/initializeNotifications.ts"],"mappings":";;AAAA,SACEA,KAAK,EACLC,QAAQ,EAGRC,QAAQ,QACH,cAAc;AACrB,SAASC,mBAAmB,QAAQ,YAAG;AACvC,SACEC,YAAY,EACZC,4BAA4B,QAEvB,oBAAiB;AACxB,SAASC,WAAW,QAAQ,mBAAgB;AAC5C,SAASC,YAAY,EAAEC,aAAa,QAAQ,eAAY;AACxD,SAASC,QAAQ,QAAQ,yBAAsB;AAC/C,SAASC,WAAW,QAAQ,4BAAyB;AAErD,IAAIC,mBAAmB,GAAG;EACxBC,4BAA4B,EAAE,EAA2B;EACzDC,qBAAqB,EAAE;AACzB,CAAC;AAED,IAAIC,cAAc,GAAG,KAAK;AAS1B,SAASC,eAAeA,CAAA,EAAG;EACzB,IAAIb,QAAQ,CAACc,EAAE,KAAK,KAAK,IAAIF,cAAc,EAAE;IAC3C;EACF;EAEAA,cAAc,GAAG,IAAI;EACrBd,KAAK,CAACiB,KAAK,CACTR,QAAQ,CAAC,2BAA2B,CAAC,EACrCA,QAAQ,CAAC,iCAAiC,CAAC,EAC3C,CACE;IACES,IAAI,EAAET,QAAQ,CAAC,4BAA4B,CAAC;IAC5CU,KAAK,EAAE,QAAQ;IACfC,OAAO,EAAEA,CAAA,KAAM;MACbN,cAAc,GAAG,KAAK;IACxB;EACF,CAAC,EACD;IACEI,IAAI,EAAET,QAAQ,CAAC,kCAAkC,CAAC;IAClDW,OAAO,EAAEA,CAAA,KAAM;MACbN,cAAc,GAAG,KAAK;MACtBX,mBAAmB,CAACkB,cAAc,CAAC,CAAC;IACtC;EACF,CAAC,CAEL,CAAC;AACH;AAEA,SAASC,sBAAsBA,CAACC,MAAoC,EAAE;EACpE,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AAM;QACL,IAAIqB,MAAM,CAACkB,qBAAqB,EAAE;UAChCpE,mBAAmB,CAAC+D,KAAK,CAAC,CAAC,CAACtB,IAAI,CAAC,MAAO4B,qBAAqB,IAAK;YAChElD,sBAAsB,CAACkD,qBAAqB,CAAC;YAC7C,IACEA,qBAAqB,KAAKnE,4BAA4B,CAACqB,OAAO,EAC9D;cACA,MAAMK,6BAA6B,CAACC,OAAO,CAAC;YAC9C,CAAC,MAAM,IACLwC,qBAAqB,KAAKnE,4BAA4B,CAAC8D,OAAO,EAC9D;cACA,IAAId,MAAM,CAAChC,cAAc,EAAE;gBACzBN,eAAe,CAAC,CAAC;cACnB;YACF;UACF,CAAC,CAAC;QACJ;MACF;IACF;EACF,CACF,CAAC;EAED,OAAOyC,MAAM;AACf","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createJSONStorage","persist","shallow","createWithEqualityFn","AsyncStorage","storeCreator","set","get","baseWidth","baseHeight","initialized","customer","data","language","theme","fake","themes","firstMessage","formSubmitted","setData","cb","newData","setFirstMessage","message","setCustomer","createCustomerResponse","name","setLanguage","setTheme","setFake","setThemes","updateBaseDimensions","setForm","form","permissionGiven","setPermissionGiven","notificationInitialized","setNotificationInitialized","toastMessage","setToastMessage","registered","setRegistered","useAppStore","storage","skipHydration","partialize","state"],"sourceRoot":"../../../src","sources":["store/store.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,OAAO,QAAQ,oBAAoB;AAC/D,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,oBAAoB,QAAQ,qBAAqB;AAE1D,OAAOC,YAAY,MAAM,2CAA2C;
|
|
1
|
+
{"version":3,"names":["createJSONStorage","persist","shallow","createWithEqualityFn","AsyncStorage","storeCreator","set","get","baseWidth","baseHeight","initialized","customer","data","language","theme","fake","themes","firstMessage","formSubmitted","setData","cb","newData","setFirstMessage","message","setCustomer","createCustomerResponse","name","setLanguage","setTheme","setFake","setThemes","updateBaseDimensions","setForm","form","permissionGiven","setPermissionGiven","notificationInitialized","setNotificationInitialized","toastMessage","setToastMessage","token","setToken","registered","setRegistered","useAppStore","storage","skipHydration","partialize","state"],"sourceRoot":"../../../src","sources":["store/store.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,OAAO,QAAQ,oBAAoB;AAC/D,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,oBAAoB,QAAQ,qBAAqB;AAE1D,OAAOC,YAAY,MAAM,2CAA2C;AA6CpE,OAAO,MAAMC,YAAyC,GAAGA,CAACC,GAAG,EAAEC,GAAG,MAAM;EACtEC,SAAS,EAAE,GAAG;EACdC,UAAU,EAAE,GAAG;EACfC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE,IAAI;EACdC,IAAI,EAAE,IAAI;EACVC,QAAQ,EAAE,IAAI;EACdC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,KAAK;EACXC,MAAM,EAAE,CAAC,CAAC;EACVC,YAAY,EAAE,IAAI;EAClBC,aAAa,EAAE,KAAK;EACpBC,OAAO,EAAGC,EAAE,IAAK;IACf,MAAMC,OAAO,GAAGD,EAAE,CAACb,GAAG,CAAC,CAAC,CAACK,IAAI,CAAC;IAC9BN,GAAG,CAAC;MAAEM,IAAI,EAAES;IAAQ,CAAC,CAAC;EACxB,CAAC;EACDC,eAAe,EAAGC,OAAO,IAAK;IAC5BjB,GAAG,CAAC;MAAEW,YAAY,EAAEM;IAAQ,CAAC,CAAC;EAChC,CAAC;EACDC,WAAW,EAAGC,sBAAuC,IAAK;IACxDnB,GAAG,CAAC;MACFK,QAAQ,EAAEc,sBAAsB;MAChCP,aAAa,EAAE,CAAC,CAACO,sBAAsB,EAAEC;IAC3C,CAAC,CAAC;EACJ,CAAC;EACDC,WAAW,EAAGd,QAAsB,IAAK;IACvCP,GAAG,CAAC;MAAEO;IAAS,CAAC,CAAC;EACnB,CAAC;EACDe,QAAQ,EAAGd,KAAuB,IAAK;IACrCR,GAAG,CAA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5BmB,OAAO,EAAE7C,iBAAiB,CAAC,MAAMI,YAAY,CAAC;EAC9C0C,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAGC,KAAK,KAAM;IACtBrC,QAAQ,EAAEqC,KAAK,CAACrC,QAAQ;IACxBO,aAAa,EAAE8B,KAAK,CAAC9B,aAAa;IAClCgB,eAAe,EAAEc,KAAK,CAACd;EACzB,CAAC;AACH,CAAC,CAAC,EACFhC,OACF,CAAC","ignoreList":[]}
|
package/lib/module/version.js
CHANGED
|
@@ -3,8 +3,11 @@ export declare enum NotificationPermissionStatus {
|
|
|
3
3
|
DENIED = "denied",
|
|
4
4
|
BLOCKED = "blocked"
|
|
5
5
|
}
|
|
6
|
+
export interface InitializeOptions {
|
|
7
|
+
logLevel?: 'verbose' | 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
8
|
+
}
|
|
6
9
|
export interface NativeComnyx {
|
|
7
|
-
initialize(): Promise<{
|
|
10
|
+
initialize(options?: InitializeOptions): Promise<{
|
|
8
11
|
success: boolean;
|
|
9
12
|
country: string;
|
|
10
13
|
language: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeComnyx.d.ts","sourceRoot":"","sources":["../../../src/NativeComnyx.ts"],"names":[],"mappings":"AAEA,oBAAY,4BAA4B;IACtC,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,
|
|
1
|
+
{"version":3,"file":"NativeComnyx.d.ts","sourceRoot":"","sources":["../../../src/NativeComnyx.ts"],"names":[],"mappings":"AAEA,oBAAY,4BAA4B;IACtC,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CACrE;AACD,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAC/C,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,UAAU,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACpD,KAAK,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC/C,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD;AAED,eAAO,MAAM,YAAY,cAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useListenNativeTokenForDebug.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useListenNativeTokenForDebug.ts"],"names":[],"mappings":"AAGA,wBAAgB,4BAA4B,eAE3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -2,6 +2,7 @@ export interface InitializeNotificationsParams {
|
|
|
2
2
|
showOptIn?: boolean;
|
|
3
3
|
showOptInOnForeground?: boolean;
|
|
4
4
|
linkToSettings?: boolean;
|
|
5
|
+
logLevel?: 'verbose' | 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
5
6
|
}
|
|
6
7
|
export declare function initializeNotifications(params?: InitializeNotificationsParams): Promise<boolean>;
|
|
7
8
|
//# sourceMappingURL=initializeNotifications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeNotifications.d.ts","sourceRoot":"","sources":["../../../../src/notifications/initializeNotifications.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initializeNotifications.d.ts","sourceRoot":"","sources":["../../../../src/notifications/initializeNotifications.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CACrE;AA0FD,wBAAsB,uBAAuB,CAC3C,MAAM,GAAE,6BAAkC,oBAqF3C"}
|
|
@@ -34,6 +34,8 @@ interface AppStoreState {
|
|
|
34
34
|
setToastMessage: (message: keyof LocalizationKeys | null) => void;
|
|
35
35
|
registered: boolean;
|
|
36
36
|
setRegistered: (registered: boolean) => void;
|
|
37
|
+
token: string | null;
|
|
38
|
+
setToken: (token: string) => void;
|
|
37
39
|
}
|
|
38
40
|
export declare const storeCreator: StateCreator<AppStoreState>;
|
|
39
41
|
export declare const useAppStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<Omit<import("zustand").StoreApi<AppStoreState>, "persist"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,CACP,EAAE,EAAE,CACF,QAAQ,EAAE,sBAAsB,EAAE,GAAG,IAAI,KACtC,sBAAsB,EAAE,GAAG,IAAI,KACjC,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,CAA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;IACzB,kBAAkB,EAAE,CAAC,eAAe,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,uBAAuB,EAAE,OAAO,CAAC;IACjC,0BAA0B,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,IAAI,CAAC;IACvE,YAAY,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;IAClE,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,aAAa,CA+DnD,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;EAYvB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.12.
|
|
1
|
+
export declare const VERSION = "0.12.6";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developer_tribe/react-native-comnyx",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"description": "React Native chat component with integrated support panel, enabling real-time customer communication and efficient agent workflow management.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
package/src/NativeComnyx.ts
CHANGED
|
@@ -6,8 +6,11 @@ export enum NotificationPermissionStatus {
|
|
|
6
6
|
BLOCKED = 'blocked',
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export interface InitializeOptions {
|
|
10
|
+
logLevel?: 'verbose' | 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
11
|
+
}
|
|
9
12
|
export interface NativeComnyx {
|
|
10
|
-
initialize(): Promise<{
|
|
13
|
+
initialize(options?: InitializeOptions): Promise<{
|
|
11
14
|
success: boolean;
|
|
12
15
|
country: string;
|
|
13
16
|
language: string;
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
Platform,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { ComnyxNotifications } from '.';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
nativeComnyx,
|
|
11
|
+
NotificationPermissionStatus,
|
|
12
|
+
type InitializeOptions,
|
|
13
|
+
} from '../NativeComnyx';
|
|
10
14
|
import { useAppStore } from '../store/store';
|
|
11
15
|
import { isInitCalled, isLoginCalled } from '../api/api';
|
|
12
16
|
import { localize } from '../hooks/useLocalize';
|
|
@@ -23,6 +27,7 @@ export interface InitializeNotificationsParams {
|
|
|
23
27
|
showOptIn?: boolean;
|
|
24
28
|
showOptInOnForeground?: boolean;
|
|
25
29
|
linkToSettings?: boolean;
|
|
30
|
+
logLevel?: 'verbose' | 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
function showAlertDialog() {
|
|
@@ -74,12 +79,13 @@ function changePermissionStatus(status: NotificationPermissionStatus) {
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
async function initializeNativeNotifications() {
|
|
82
|
+
async function initializeNativeNotifications(options: InitializeOptions) {
|
|
78
83
|
const state = useAppStore.getState();
|
|
79
84
|
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
80
85
|
globalSubscriptions.subscriptionsForNotification = [
|
|
81
86
|
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
|
|
82
87
|
if (Platform.OS === 'ios') {
|
|
88
|
+
useAppStore.getState().setToken(data.token);
|
|
83
89
|
accumulator.add({
|
|
84
90
|
apnsToken: data.token,
|
|
85
91
|
});
|
|
@@ -94,7 +100,11 @@ async function initializeNativeNotifications() {
|
|
|
94
100
|
console.error('TOKEN_FAILED', data);
|
|
95
101
|
}),
|
|
96
102
|
];
|
|
97
|
-
|
|
103
|
+
var sendOptions: InitializeOptions | undefined = options;
|
|
104
|
+
if (Platform.OS === 'ios') {
|
|
105
|
+
sendOptions = undefined;
|
|
106
|
+
}
|
|
107
|
+
return await nativeComnyx.initialize(sendOptions).then((res) => {
|
|
98
108
|
state.setNotificationInitialized(true);
|
|
99
109
|
if (res.success) {
|
|
100
110
|
accumulator.add({
|
|
@@ -117,7 +127,9 @@ export async function initializeNotifications(
|
|
|
117
127
|
if (!isLoginCalled()) {
|
|
118
128
|
throw new Error('Please call login first');
|
|
119
129
|
}
|
|
120
|
-
|
|
130
|
+
const options: InitializeOptions = {
|
|
131
|
+
logLevel: params.logLevel ?? 'warn',
|
|
132
|
+
};
|
|
121
133
|
let result: boolean = false;
|
|
122
134
|
|
|
123
135
|
if (globalSubscriptions.subscriptionsForNotification.length > 0) {
|
|
@@ -132,7 +144,7 @@ export async function initializeNotifications(
|
|
|
132
144
|
const permissionResult = await ComnyxNotifications.checkOptIn();
|
|
133
145
|
changePermissionStatus(permissionResult);
|
|
134
146
|
if (permissionResult === NotificationPermissionStatus.GRANTED) {
|
|
135
|
-
result = await initializeNativeNotifications();
|
|
147
|
+
result = await initializeNativeNotifications(options);
|
|
136
148
|
} else {
|
|
137
149
|
if (params.showOptIn) {
|
|
138
150
|
if (permissionResult === NotificationPermissionStatus.DENIED) {
|
|
@@ -167,7 +179,7 @@ export async function initializeNotifications(
|
|
|
167
179
|
) {
|
|
168
180
|
const state = useAppStore.getState();
|
|
169
181
|
if (!state.notificationInitialized) {
|
|
170
|
-
await initializeNativeNotifications();
|
|
182
|
+
await initializeNativeNotifications(options);
|
|
171
183
|
}
|
|
172
184
|
} else {
|
|
173
185
|
if (params.showOptInOnForeground) {
|
|
@@ -176,7 +188,7 @@ export async function initializeNotifications(
|
|
|
176
188
|
if (
|
|
177
189
|
permissionResultInner === NotificationPermissionStatus.GRANTED
|
|
178
190
|
) {
|
|
179
|
-
await initializeNativeNotifications();
|
|
191
|
+
await initializeNativeNotifications(options);
|
|
180
192
|
} else if (
|
|
181
193
|
permissionResultInner === NotificationPermissionStatus.BLOCKED
|
|
182
194
|
) {
|
package/src/store/store.ts
CHANGED
|
@@ -43,6 +43,8 @@ interface AppStoreState {
|
|
|
43
43
|
setToastMessage: (message: keyof LocalizationKeys | null) => void;
|
|
44
44
|
registered: boolean;
|
|
45
45
|
setRegistered: (registered: boolean) => void;
|
|
46
|
+
token: string | null;
|
|
47
|
+
setToken: (token: string) => void;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
@@ -100,6 +102,10 @@ export const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
|
100
102
|
setToastMessage: (message: keyof LocalizationKeys | null) => {
|
|
101
103
|
set({ toastMessage: message });
|
|
102
104
|
},
|
|
105
|
+
token: null,
|
|
106
|
+
setToken: (token: string) => {
|
|
107
|
+
set({ token });
|
|
108
|
+
},
|
|
103
109
|
registered: false,
|
|
104
110
|
setRegistered: (registered: boolean) => {
|
|
105
111
|
set({ registered });
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const VERSION = '0.12.
|
|
2
|
+
export const VERSION = '0.12.6';
|