@developer_tribe/react-native-comnyx 0.10.0 → 0.10.1
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/src/messaging/firebase/FirebaseMessagingService.kt +5 -1
- package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +2 -2
- package/lib/commonjs/notifications/initializeNotifications.js +16 -16
- package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
- package/lib/module/notifications/initializeNotifications.js +16 -16
- package/lib/module/notifications/initializeNotifications.js.map +1 -1
- package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/notifications/initializeNotifications.ts +21 -19
|
@@ -18,7 +18,11 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
|
|
|
18
18
|
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
19
19
|
//https://stackoverflow.com/a/40083727
|
|
20
20
|
super.onMessageReceived(remoteMessage)
|
|
21
|
-
|
|
21
|
+
val isCustom = remoteMessage.data["custom"] == "true"
|
|
22
|
+
|
|
23
|
+
if (isCustom) {
|
|
24
|
+
notificationsHelper.showNotification(remoteMessage)
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
override fun onNewToken(token: String) {
|
package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt
CHANGED
|
@@ -122,9 +122,9 @@ class NotificationsHelper(private val context: Context) {
|
|
|
122
122
|
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
|
|
123
123
|
.setContentTitle(title)
|
|
124
124
|
.setContentText(message)
|
|
125
|
-
.setSmallIcon(
|
|
125
|
+
.setSmallIcon(context.resources.getIdentifier("com_google_firebase_messaging_default_notification_icon", "drawable", context.packageName))
|
|
126
126
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
127
|
-
|
|
127
|
+
//.setNumber(100)
|
|
128
128
|
.setAutoCancel(true)
|
|
129
129
|
.setContentIntent(pendingIntent)
|
|
130
130
|
|
|
@@ -42,10 +42,26 @@ function changePermissionStatus(status) {
|
|
|
42
42
|
}
|
|
43
43
|
async function initializeNativeNotifications() {
|
|
44
44
|
const state = _store.useAppStore.getState();
|
|
45
|
+
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
46
|
+
globalSubscriptions.subscriptionsForNotification = [_index.ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
47
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
48
|
+
_Accumulator.accumulator.add({
|
|
49
|
+
apnsToken: data.token
|
|
50
|
+
});
|
|
51
|
+
} else if (_reactNative.Platform.OS === 'android') {
|
|
52
|
+
_Accumulator.accumulator.add({
|
|
53
|
+
fcmToken: data.token
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}), _index.ComnyxNotifications.addEventListener('TOKEN_FAILED', data => {
|
|
57
|
+
//TODO: logger
|
|
58
|
+
console.error('TOKEN_FAILED', data);
|
|
59
|
+
})];
|
|
45
60
|
return await _NativeComnyx.nativeComnyx.initialize().then(res => {
|
|
46
61
|
state.setNotificationInitialized(true);
|
|
47
62
|
if (res.success) {
|
|
48
63
|
_Accumulator.accumulator.add({
|
|
64
|
+
platform: _reactNative.Platform.OS,
|
|
49
65
|
country: res.country,
|
|
50
66
|
language: res.language,
|
|
51
67
|
//ComnyxSupport burayı override ediyor!.
|
|
@@ -116,22 +132,6 @@ async function initializeNotifications(params = {}) {
|
|
|
116
132
|
}
|
|
117
133
|
}
|
|
118
134
|
});
|
|
119
|
-
globalSubscriptions.subscriptionsForNotification = [_index.ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
120
|
-
if (_reactNative.Platform.OS === 'ios') {
|
|
121
|
-
_Accumulator.accumulator.add({
|
|
122
|
-
apnsToken: data.token,
|
|
123
|
-
platform: 'ios'
|
|
124
|
-
});
|
|
125
|
-
} else if (_reactNative.Platform.OS === 'android') {
|
|
126
|
-
_Accumulator.accumulator.add({
|
|
127
|
-
fcmToken: data.token,
|
|
128
|
-
platform: 'android'
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}), _index.ComnyxNotifications.addEventListener('TOKEN_FAILED', data => {
|
|
132
|
-
//TODO: logger
|
|
133
|
-
console.error('TOKEN_FAILED', data);
|
|
134
|
-
})];
|
|
135
135
|
return result;
|
|
136
136
|
}
|
|
137
137
|
//# sourceMappingURL=initializeNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_index","_NativeComnyx","_store","_api","_useLocalize","_Accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","showAlertDialog","Alert","alert","localize","text","style","onPress","ComnyxNotifications","linkToSettings","changePermissionStatus","status","state","useAppStore","getState","NotificationPermissionStatus","GRANTED","setPermissionGiven","accumulator","add","allow_notifications","initializeNativeNotifications","nativeComnyx","initialize","then","res","setNotificationInitialized","success","country","language","timezone","initializeNotifications","params","isInitCalled","Error","isLoginCalled","result","length","forEach","subscription","remove","permissionResult","checkOptIn","showOptIn","DENIED","permissionResultAfterDenied","optIn","BLOCKED","AppState","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_index","_NativeComnyx","_store","_api","_useLocalize","_Accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","showAlertDialog","Alert","alert","localize","text","style","onPress","ComnyxNotifications","linkToSettings","changePermissionStatus","status","state","useAppStore","getState","NotificationPermissionStatus","GRANTED","setPermissionGiven","accumulator","add","allow_notifications","initializeNativeNotifications","addEventListener","data","Platform","OS","apnsToken","token","fcmToken","console","error","nativeComnyx","initialize","then","res","setNotificationInitialized","success","platform","country","language","timezone","initializeNotifications","params","isInitCalled","Error","isLoginCalled","result","length","forEach","subscription","remove","permissionResult","checkOptIn","showOptIn","DENIED","permissionResultAfterDenied","optIn","BLOCKED","AppState","nextAppState","permissionGivenInForeground","notificationInitialized","showOptInOnForeground","permissionResultInner"],"sourceRoot":"../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qBAAQ,CAACpC,gBAAgB,CACnE,QAAQ,EACR,MAAOqC,YAAY,IAAK;IACtB,IAAIA,YAAY,KAAK,QAAQ,EAAE;MAC7B,MAAMC,2BAA2B,GAC/B,CAAC,MAAMpD,0BAAmB,CAAC4C,UAAU,CAAC,CAAC,MACvCrC,0CAA4B,CAACC,OAAO;MACtC,IAAI4C,2BAA2B,EAAE;QAC/BhD,KAAK,CAACK,kBAAkB,CAAC,IAAI,CAAC;QAC9B,IAAI,CAACL,KAAK,CAACiD,uBAAuB,EAAE;UAClC,MAAMrD,0BAAmB,CAACwB,UAAU,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;YAChDrB,KAAK,CAACuB,0BAA0B,CAAC,IAAI,CAAC;UACxC,CAAC,CAAC;QACJ;MACF,CAAC,MAAM;QACL,IAAIO,MAAM,CAACoB,qBAAqB,EAAE;UAChCtD,0BAAmB,CAACgD,KAAK,CAAC,CAAC,CAACvB,IAAI,CAAC,MAAO8B,qBAAqB,IAAK;YAChErD,sBAAsB,CAACqD,qBAAqB,CAAC;YAC7C,IACEA,qBAAqB,KAAKhD,0CAA4B,CAACC,OAAO,EAC9D;cACA,MAAMK,6BAA6B,CAAC,CAAC;YACvC,CAAC,MAAM,IACL0C,qBAAqB,KAAKhD,0CAA4B,CAAC0C,OAAO,EAC9D;cACA,IAAIf,MAAM,CAACjC,cAAc,EAAE;gBACzBR,eAAe,CAAC,CAAC;cACnB;YACF;UACF,CAAC,CAAC;QACJ;MACF;IACF;EACF,CACF,CAAC;EAGD,OAAO6C,MAAM;AACf","ignoreList":[]}
|
|
@@ -38,10 +38,26 @@ function changePermissionStatus(status) {
|
|
|
38
38
|
}
|
|
39
39
|
async function initializeNativeNotifications() {
|
|
40
40
|
const state = useAppStore.getState();
|
|
41
|
+
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
42
|
+
globalSubscriptions.subscriptionsForNotification = [ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
43
|
+
if (Platform.OS === 'ios') {
|
|
44
|
+
accumulator.add({
|
|
45
|
+
apnsToken: data.token
|
|
46
|
+
});
|
|
47
|
+
} else if (Platform.OS === 'android') {
|
|
48
|
+
accumulator.add({
|
|
49
|
+
fcmToken: data.token
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}), ComnyxNotifications.addEventListener('TOKEN_FAILED', data => {
|
|
53
|
+
//TODO: logger
|
|
54
|
+
console.error('TOKEN_FAILED', data);
|
|
55
|
+
})];
|
|
41
56
|
return await nativeComnyx.initialize().then(res => {
|
|
42
57
|
state.setNotificationInitialized(true);
|
|
43
58
|
if (res.success) {
|
|
44
59
|
accumulator.add({
|
|
60
|
+
platform: Platform.OS,
|
|
45
61
|
country: res.country,
|
|
46
62
|
language: res.language,
|
|
47
63
|
//ComnyxSupport burayı override ediyor!.
|
|
@@ -112,22 +128,6 @@ export async function initializeNotifications(params = {}) {
|
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
});
|
|
115
|
-
globalSubscriptions.subscriptionsForNotification = [ComnyxNotifications.addEventListener('TOKEN_INIT', data => {
|
|
116
|
-
if (Platform.OS === 'ios') {
|
|
117
|
-
accumulator.add({
|
|
118
|
-
apnsToken: data.token,
|
|
119
|
-
platform: 'ios'
|
|
120
|
-
});
|
|
121
|
-
} else if (Platform.OS === 'android') {
|
|
122
|
-
accumulator.add({
|
|
123
|
-
fcmToken: data.token,
|
|
124
|
-
platform: 'android'
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}), ComnyxNotifications.addEventListener('TOKEN_FAILED', data => {
|
|
128
|
-
//TODO: logger
|
|
129
|
-
console.error('TOKEN_FAILED', data);
|
|
130
|
-
})];
|
|
131
131
|
return result;
|
|
132
132
|
}
|
|
133
133
|
//# sourceMappingURL=initializeNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Alert","AppState","Platform","ComnyxNotifications","nativeComnyx","NotificationPermissionStatus","useAppStore","isInitCalled","isLoginCalled","localize","accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","showAlertDialog","alert","text","style","onPress","linkToSettings","changePermissionStatus","status","state","getState","GRANTED","setPermissionGiven","add","allow_notifications","initializeNativeNotifications","initialize","then","res","setNotificationInitialized","success","country","language","timezone","initializeNotifications","params","Error","result","length","forEach","subscription","remove","permissionResult","checkOptIn","showOptIn","DENIED","permissionResultAfterDenied","optIn","BLOCKED","
|
|
1
|
+
{"version":3,"names":["Alert","AppState","Platform","ComnyxNotifications","nativeComnyx","NotificationPermissionStatus","useAppStore","isInitCalled","isLoginCalled","localize","accumulator","globalSubscriptions","subscriptionsForNotification","subscriptionsForOptIn","showAlertDialog","alert","text","style","onPress","linkToSettings","changePermissionStatus","status","state","getState","GRANTED","setPermissionGiven","add","allow_notifications","initializeNativeNotifications","addEventListener","data","OS","apnsToken","token","fcmToken","console","error","initialize","then","res","setNotificationInitialized","success","platform","country","language","timezone","initializeNotifications","params","Error","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,SAASC,YAAY,EAAEC,4BAA4B,QAAQ,oBAAiB;AAC5E,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;AAQD,SAASC,eAAeA,CAAA,EAAG;EACzBd,KAAK,CAACe,KAAK,CACTN,QAAQ,CAAC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IAAI,CAAC;UACxC,CAAC,CAAC;QACJ;MACF,CAAC,MAAM;QACL,IAAIO,MAAM,CAACiB,qBAAqB,EAAE;UAChC7D,mBAAmB,CAACwD,KAAK,CAAC,CAAC,CAACrB,IAAI,CAAC,MAAO2B,qBAAqB,IAAK;YAChE7C,sBAAsB,CAAC6C,qBAAqB,CAAC;YAC7C,IACEA,qBAAqB,KAAK5D,4BAA4B,CAACmB,OAAO,EAC9D;cACA,MAAMI,6BAA6B,CAAC,CAAC;YACvC,CAAC,MAAM,IACLqC,qBAAqB,KAAK5D,4BAA4B,CAACuD,OAAO,EAC9D;cACA,IAAIb,MAAM,CAAC5B,cAAc,EAAE;gBACzBL,eAAe,CAAC,CAAC;cACnB;YACF;UACF,CAAC,CAAC;QACJ;MACF;IACF;EACF,CACF,CAAC;EAGD,OAAOmC,MAAM;AACf","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeNotifications.d.ts","sourceRoot":"","sources":["../../../../src/notifications/initializeNotifications.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"initializeNotifications.d.ts","sourceRoot":"","sources":["../../../../src/notifications/initializeNotifications.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAwED,wBAAsB,uBAAuB,CAC3C,MAAM,GAAE,6BAAkC,oBAqF3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developer_tribe/react-native-comnyx",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
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",
|
|
@@ -60,10 +60,30 @@ function changePermissionStatus(status: NotificationPermissionStatus) {
|
|
|
60
60
|
|
|
61
61
|
async function initializeNativeNotifications() {
|
|
62
62
|
const state = useAppStore.getState();
|
|
63
|
+
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
64
|
+
globalSubscriptions.subscriptionsForNotification = [
|
|
65
|
+
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
|
|
66
|
+
if (Platform.OS === 'ios') {
|
|
67
|
+
accumulator.add({
|
|
68
|
+
apnsToken: data.token,
|
|
69
|
+
});
|
|
70
|
+
} else if (Platform.OS === 'android') {
|
|
71
|
+
accumulator.add({
|
|
72
|
+
fcmToken: data.token,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
|
|
77
|
+
//TODO: logger
|
|
78
|
+
console.error('TOKEN_FAILED', data);
|
|
79
|
+
}),
|
|
80
|
+
];
|
|
63
81
|
return await nativeComnyx.initialize().then((res) => {
|
|
64
82
|
state.setNotificationInitialized(true);
|
|
65
83
|
if (res.success) {
|
|
84
|
+
|
|
66
85
|
accumulator.add({
|
|
86
|
+
platform: Platform.OS,
|
|
67
87
|
country: res.country,
|
|
68
88
|
language: res.language, //ComnyxSupport burayı override ediyor!.
|
|
69
89
|
timezone: res.timezone,
|
|
@@ -157,24 +177,6 @@ export async function initializeNotifications(
|
|
|
157
177
|
}
|
|
158
178
|
);
|
|
159
179
|
|
|
160
|
-
|
|
161
|
-
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
|
|
162
|
-
if (Platform.OS === 'ios') {
|
|
163
|
-
accumulator.add({
|
|
164
|
-
apnsToken: data.token,
|
|
165
|
-
platform: 'ios',
|
|
166
|
-
});
|
|
167
|
-
} else if (Platform.OS === 'android') {
|
|
168
|
-
accumulator.add({
|
|
169
|
-
fcmToken: data.token,
|
|
170
|
-
platform: 'android',
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
|
|
175
|
-
//TODO: logger
|
|
176
|
-
console.error('TOKEN_FAILED', data);
|
|
177
|
-
}),
|
|
178
|
-
];
|
|
180
|
+
|
|
179
181
|
return result;
|
|
180
182
|
}
|