infobip-mobile-messaging-react-native-plugin 4.0.2 → 4.1.2
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/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +14 -13
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/CacheManager.java +8 -11
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatModule.java +11 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingModule.java +42 -32
- package/index.js +20 -1
- package/infobip-mobile-messaging-react-native-plugin-4.1.1.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +3 -3
- package/ios/Cartfile +1 -1
- package/ios/Cartfile.resolved +1 -1
- package/ios/MobileMessagingPlugin/RNMMChat.swift +18 -8
- package/ios/MobileMessagingPlugin/RNMMChatBridge.m +2 -0
- package/ios/MobileMessagingPlugin/RNMobileMessaging.swift +2 -1
- package/ios/MobileMessagingPlugin/RNMobileMessagingEventsManager.swift +5 -1
- package/ios/MobileMessagingPlugin/RNMobileMessagingUtils.swift +1 -0
- package/package.json +1 -1
- package/infobip-mobile-messaging-react-native-plugin-4.0.1.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -20,42 +20,43 @@
|
|
|
20
20
|
<!-- Mobile Messaging components -->
|
|
21
21
|
|
|
22
22
|
<service
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
android:name="org.infobip.mobile.messaging.cloud.firebase.MobileMessagingFirebaseService"
|
|
24
|
+
android:exported="false" >
|
|
25
25
|
<intent-filter>
|
|
26
26
|
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
27
27
|
</intent-filter>
|
|
28
28
|
</service>
|
|
29
29
|
|
|
30
30
|
<service
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
android:name="org.infobip.mobile.messaging.cloud.MobileMessagingCloudService"
|
|
32
|
+
android:permission="android.permission.BIND_JOB_SERVICE"
|
|
33
|
+
android:exported="false" >
|
|
34
34
|
</service>
|
|
35
35
|
|
|
36
36
|
<service
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
android:name="org.infobip.mobile.messaging.platform.MobileMessagingJobService"
|
|
38
|
+
android:enabled="false"
|
|
39
|
+
android:exported="false"
|
|
40
|
+
android:permission="android.permission.BIND_JOB_SERVICE" />
|
|
41
41
|
|
|
42
42
|
<receiver android:name="org.infobip.mobile.messaging.notification.NotificationTapReceiver" />
|
|
43
43
|
|
|
44
44
|
<receiver
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
android:name="org.infobip.mobile.messaging.MobileMessagingConnectivityReceiver"
|
|
46
|
+
android:enabled="false"
|
|
47
|
+
android:exported="false">
|
|
48
48
|
<intent-filter>
|
|
49
49
|
<!-- Intent filter is for pre-7.0 Nougat devices -->
|
|
50
50
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
|
51
51
|
</intent-filter>
|
|
52
52
|
</receiver>
|
|
53
53
|
<receiver android:name="org.infobip.mobile.messaging.interactive.notification.NotificationActionTapReceiver" />
|
|
54
|
-
<receiver android:name="org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule$
|
|
54
|
+
<receiver android:name="org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule$MessageEventReceiver" android:exported="false">
|
|
55
55
|
<intent-filter>
|
|
56
56
|
<action android:name="org.infobip.mobile.messaging.MESSAGE_RECEIVED" />
|
|
57
57
|
<action android:name="org.infobip.mobile.messaging.NOTIFICATION_TAPPED" />
|
|
58
58
|
<action android:name="org.infobip.mobile.messaging.interactive.NOTIFICATION_ACTION_TAPPED" />
|
|
59
|
+
<action android:name="org.infobip.mobile.messaging.chat.UNREAD_MESSAGES_COUNTER_UPDATED"/>
|
|
59
60
|
</intent-filter>
|
|
60
61
|
</receiver>
|
|
61
62
|
|
|
@@ -3,11 +3,7 @@ package org.infobip.reactlibrary.mobilemessaging;
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.content.SharedPreferences;
|
|
5
5
|
import android.preference.PreferenceManager;
|
|
6
|
-
import android.util.Log;
|
|
7
6
|
|
|
8
|
-
import com.facebook.react.bridge.ReactContext;
|
|
9
|
-
|
|
10
|
-
import org.infobip.mobile.messaging.Message;
|
|
11
7
|
import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
|
|
12
8
|
import org.infobip.mobile.messaging.dal.json.JSONArrayAdapter;
|
|
13
9
|
import org.infobip.mobile.messaging.dal.json.JSONObjectAdapter;
|
|
@@ -26,15 +22,11 @@ class CacheManager {
|
|
|
26
22
|
|
|
27
23
|
static class Event {
|
|
28
24
|
String type;
|
|
29
|
-
|
|
30
|
-
String actionId = null;
|
|
31
|
-
String actionInputText = null;
|
|
25
|
+
Object[] objects = null;
|
|
32
26
|
|
|
33
|
-
Event(String type,
|
|
27
|
+
Event(String type, Object ... objects) {
|
|
34
28
|
this.type = type;
|
|
35
|
-
this.
|
|
36
|
-
this.actionId = actionId;
|
|
37
|
-
this.actionInputText = actionInputText;
|
|
29
|
+
this.objects = objects;
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
@Override
|
|
@@ -48,6 +40,11 @@ class CacheManager {
|
|
|
48
40
|
saveStringsToSet(context, EVENTS_KEY, serialized);
|
|
49
41
|
}
|
|
50
42
|
|
|
43
|
+
static void saveEvent(Context context, String event, int unreadMessagesCounter) {
|
|
44
|
+
String serialized = serializer.serialize(new Event(event, unreadMessagesCounter));
|
|
45
|
+
saveStringsToSet(context, EVENTS_KEY, serialized);
|
|
46
|
+
}
|
|
47
|
+
|
|
51
48
|
static Event[] loadEvents(Context context) {
|
|
52
49
|
Set<String> serialized = getAndRemoveStringSet(context, EVENTS_KEY);
|
|
53
50
|
List<Event> events = new ArrayList<Event>(serialized.size());
|
|
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment;
|
|
|
9
9
|
import androidx.fragment.app.FragmentActivity;
|
|
10
10
|
|
|
11
11
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
12
|
+
import com.facebook.react.bridge.Callback;
|
|
12
13
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
13
14
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
14
15
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
@@ -39,6 +40,16 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
|
|
|
39
40
|
InAppChat.getInstance(reactContext).inAppChatView().show();
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
@ReactMethod
|
|
44
|
+
public void getMessageCounter(final Callback successCallback) {
|
|
45
|
+
successCallback.invoke(InAppChat.getInstance(reactContext).getMessageCounter());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
public void resetMessageCounter() {
|
|
50
|
+
InAppChat.getInstance(reactContext).resetMessageCounter();
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
@Override
|
|
43
54
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
44
55
|
FragmentActivity fragmentActivity = Utils.getFragmentActivity(reactContext);
|
|
@@ -11,12 +11,14 @@ import android.util.Log;
|
|
|
11
11
|
import androidx.annotation.NonNull;
|
|
12
12
|
import androidx.annotation.Nullable;
|
|
13
13
|
|
|
14
|
+
import com.facebook.react.ReactApplication;
|
|
14
15
|
import com.facebook.react.bridge.*;
|
|
15
16
|
import com.google.android.gms.common.ConnectionResult;
|
|
16
17
|
import com.google.android.gms.common.GoogleApiAvailability;
|
|
17
18
|
|
|
18
19
|
import org.infobip.mobile.messaging.*;
|
|
19
20
|
import org.infobip.mobile.messaging.chat.InAppChat;
|
|
21
|
+
import org.infobip.mobile.messaging.chat.core.InAppChatEvent;
|
|
20
22
|
import org.infobip.mobile.messaging.geo.GeoEvent;
|
|
21
23
|
import org.infobip.mobile.messaging.geo.MobileGeo;
|
|
22
24
|
import org.infobip.mobile.messaging.interactive.InteractiveEvent;
|
|
@@ -50,11 +52,12 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
50
52
|
private final ReactApplicationContext reactContext;
|
|
51
53
|
|
|
52
54
|
private static volatile Boolean broadcastReceiverRegistered = false;
|
|
55
|
+
private static volatile Boolean pluginInitialized = false;
|
|
53
56
|
|
|
54
57
|
public ReactNativeMobileMessagingModule(ReactApplicationContext reactContext) {
|
|
55
58
|
super(reactContext);
|
|
56
59
|
|
|
57
|
-
while (getReactApplicationContext() == null);
|
|
60
|
+
while (getReactApplicationContext() == null) ;
|
|
58
61
|
reactContext = getReactApplicationContext();
|
|
59
62
|
|
|
60
63
|
this.reactContext = reactContext;
|
|
@@ -65,8 +68,9 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
65
68
|
public void initialize() {
|
|
66
69
|
super.initialize();
|
|
67
70
|
for (CacheManager.Event event : CacheManager.loadEvents(reactContext)) {
|
|
68
|
-
ReactNativeEvent.send(event.type, reactContext, event.
|
|
71
|
+
ReactNativeEvent.send(event.type, reactContext, event.objects);
|
|
69
72
|
}
|
|
73
|
+
pluginInitialized = true;
|
|
70
74
|
registerBroadcastReceiver();
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -87,6 +91,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
87
91
|
|
|
88
92
|
@Override
|
|
89
93
|
public void onHostDestroy() {
|
|
94
|
+
pluginInitialized = false;
|
|
90
95
|
unregisterBroadcastReceiver();
|
|
91
96
|
reactContext.removeLifecycleEventListener(this);
|
|
92
97
|
}
|
|
@@ -102,6 +107,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
102
107
|
private static final String EVENT_NOTIFICATION_TAPPED = "notificationTapped";
|
|
103
108
|
private static final String EVENT_NOTIFICATION_ACTION_TAPPED = "actionTapped";
|
|
104
109
|
private static final String EVENT_MESSAGE_RECEIVED = "messageReceived";
|
|
110
|
+
private static final String EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED = "inAppChat.unreadMessageCounterUpdated";
|
|
105
111
|
|
|
106
112
|
private static final Map<String, String> broadcastEventMap = new HashMap<String, String>() {{
|
|
107
113
|
put(Event.TOKEN_RECEIVED.getKey(), EVENT_TOKEN_RECEIVED);
|
|
@@ -117,6 +123,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
117
123
|
put(Event.MESSAGE_RECEIVED.getKey(), EVENT_MESSAGE_RECEIVED);
|
|
118
124
|
put(Event.NOTIFICATION_TAPPED.getKey(), EVENT_NOTIFICATION_TAPPED);
|
|
119
125
|
put(InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey(), EVENT_NOTIFICATION_ACTION_TAPPED);
|
|
126
|
+
put(InAppChatEvent.UNREAD_MESSAGES_COUNTER_UPDATED.getKey(), EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED);
|
|
120
127
|
}};
|
|
121
128
|
|
|
122
129
|
private static final Map<String, String> messageStorageEventMap = new HashMap<String, String>() {{
|
|
@@ -125,25 +132,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
125
132
|
put(MessageStoreAdapter.EVENT_MESSAGESTORAGE_FIND_ALL, MessageStoreAdapter.EVENT_MESSAGESTORAGE_FIND_ALL);
|
|
126
133
|
}};
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
private final BroadcastReceiver messageActionReceiver = new BroadcastReceiver() {
|
|
130
|
-
@Override
|
|
131
|
-
public void onReceive(Context context, Intent intent) {
|
|
132
|
-
String event = getMessageBroadcastEvent(intent);
|
|
133
|
-
if (event == null) {
|
|
134
|
-
Log.w(Utils.TAG, "Cannot process event for broadcast: " + intent.getAction());
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
JSONObject message = MessageJson.bundleToJSON(intent.getExtras());
|
|
138
|
-
if (InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey().equals(intent.getAction())) {
|
|
139
|
-
NotificationAction notificationAction = NotificationAction.createFrom(intent.getExtras());
|
|
140
|
-
ReactNativeEvent.send(event, reactContext, message, notificationAction.getId(), notificationAction.getInputText());
|
|
141
|
-
} else {
|
|
142
|
-
ReactNativeEvent.send(event, reactContext, message);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
135
|
private final BroadcastReceiver messageStorageReceiver = new BroadcastReceiver() {
|
|
148
136
|
@Override
|
|
149
137
|
public void onReceive(Context context, Intent intent) {
|
|
@@ -192,7 +180,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
192
180
|
For event caching, if plugin not yet initialized
|
|
193
181
|
*/
|
|
194
182
|
|
|
195
|
-
public static class
|
|
183
|
+
public static class MessageEventReceiver extends BroadcastReceiver {
|
|
196
184
|
@Override
|
|
197
185
|
public void onReceive(Context context, Intent intent) {
|
|
198
186
|
String event = getMessageBroadcastEvent(intent);
|
|
@@ -200,18 +188,42 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
200
188
|
Log.w(Utils.TAG, "Cannot process event for broadcast: " + intent.getAction());
|
|
201
189
|
return;
|
|
202
190
|
}
|
|
191
|
+
if (InAppChatEvent.UNREAD_MESSAGES_COUNTER_UPDATED.getKey().equals(intent.getAction())) {
|
|
192
|
+
handleUnreadMessageCounterIntent(context, intent, event);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
203
195
|
JSONObject message = MessageJson.bundleToJSON(intent.getExtras());
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
196
|
+
String actionId = null;
|
|
197
|
+
String actionInputText = null;
|
|
198
|
+
if (InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey().equals(intent.getAction())) {
|
|
199
|
+
NotificationAction notificationAction = NotificationAction.createFrom(intent.getExtras());
|
|
200
|
+
actionId = notificationAction.getId();
|
|
201
|
+
actionInputText = notificationAction.getInputText();
|
|
202
|
+
}
|
|
203
|
+
if (!pluginInitialized) {
|
|
212
204
|
CacheManager.saveEvent(context, event, message, actionId, actionInputText);
|
|
205
|
+
} else {
|
|
206
|
+
ReactContext reactContext = getReactContext(context);
|
|
207
|
+
ReactNativeEvent.send(event, reactContext, message, actionId, actionInputText);
|
|
213
208
|
}
|
|
214
209
|
}
|
|
210
|
+
|
|
211
|
+
private void handleUnreadMessageCounterIntent(Context context, Intent intent, String event) {
|
|
212
|
+
int unreadChatMessagesCounter = intent.getIntExtra(BroadcastParameter.EXTRA_UNREAD_CHAT_MESSAGES_COUNT, 0);
|
|
213
|
+
if (!pluginInitialized) {
|
|
214
|
+
CacheManager.saveEvent(context, event, unreadChatMessagesCounter);
|
|
215
|
+
} else {
|
|
216
|
+
ReactContext reactContext = getReactContext(context);
|
|
217
|
+
ReactNativeEvent.send(event, reactContext, unreadChatMessagesCounter);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Nullable
|
|
222
|
+
private ReactContext getReactContext(Context context) {
|
|
223
|
+
ReactApplication reactApplication = (ReactApplication) context.getApplicationContext();
|
|
224
|
+
if (reactApplication == null) return null;
|
|
225
|
+
return reactApplication.getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
|
|
226
|
+
}
|
|
215
227
|
}
|
|
216
228
|
|
|
217
229
|
private final BroadcastReceiver commonLibraryBroadcastReceiver = new BroadcastReceiver() {
|
|
@@ -360,7 +372,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
360
372
|
messageStorageIntentFilter.addAction(action);
|
|
361
373
|
}
|
|
362
374
|
|
|
363
|
-
reactContext.registerReceiver(messageActionReceiver, messageActionIntentFilter);
|
|
364
375
|
Context context = reactContext.getCurrentActivity();
|
|
365
376
|
LocalBroadcastManager.getInstance(context).registerReceiver(messageStorageReceiver, messageStorageIntentFilter);
|
|
366
377
|
broadcastReceiverRegistered = true;
|
|
@@ -369,7 +380,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
369
380
|
private void unregisterBroadcastReceiver() {
|
|
370
381
|
if (!broadcastReceiverRegistered) return;
|
|
371
382
|
reactContext.unregisterReceiver(commonLibraryBroadcastReceiver);
|
|
372
|
-
reactContext.unregisterReceiver(messageActionReceiver);
|
|
373
383
|
Context context = reactContext.getCurrentActivity();
|
|
374
384
|
LocalBroadcastManager.getInstance(context).unregisterReceiver(messageStorageReceiver);
|
|
375
385
|
broadcastReceiverRegistered = false;
|
package/index.js
CHANGED
|
@@ -42,8 +42,10 @@ class MobileMessaging {
|
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
this.inAppChatEvents = [
|
|
45
|
-
'inAppChat.availabilityUpdated'
|
|
45
|
+
'inAppChat.availabilityUpdated',
|
|
46
|
+
'inAppChat.unreadMessageCounterUpdated'
|
|
46
47
|
];
|
|
48
|
+
|
|
47
49
|
this.eventEmitter = new NativeEventEmitter(ReactNativeMobileMessaging);
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -522,6 +524,23 @@ class MobileMessaging {
|
|
|
522
524
|
console.log("method setupiOSChatSettings isn't supported for Android, use settings.xml to provide appearance settings.");
|
|
523
525
|
}
|
|
524
526
|
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Returns unread in-app chat push messages counter.
|
|
530
|
+
* The counter increments each time the application receives in-app chat push message
|
|
531
|
+
* (this usually happens when chat screen is inactive or the application is in background/terminated state).
|
|
532
|
+
*/
|
|
533
|
+
getMessageCounter(onResult) {
|
|
534
|
+
RNMMChat.getMessageCounter(onResult);
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* MobileMessaging plugin automatically resets the counter to 0 whenever user opens the in-app chat screen.
|
|
539
|
+
* However, use the following API in case you need to manually reset the counter.
|
|
540
|
+
*/
|
|
541
|
+
resetMessageCounter() {
|
|
542
|
+
RNMMChat.resetMessageCounter();
|
|
543
|
+
}
|
|
525
544
|
}
|
|
526
545
|
|
|
527
546
|
export class ChatView extends React.Component {
|
|
Binary file
|
|
@@ -19,8 +19,8 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.requires_arc = true
|
|
20
20
|
|
|
21
21
|
s.dependency "React-Core"
|
|
22
|
-
s.dependency "MobileMessaging/Core", "9.
|
|
23
|
-
s.dependency "MobileMessaging/Geofencing", "9.
|
|
24
|
-
s.dependency "MobileMessaging/InAppChat", "9.
|
|
22
|
+
s.dependency "MobileMessaging/Core", "9.2.7"
|
|
23
|
+
s.dependency "MobileMessaging/Geofencing", "9.2.7"
|
|
24
|
+
s.dependency "MobileMessaging/InAppChat", "9.2.7"
|
|
25
25
|
|
|
26
26
|
end
|
package/ios/Cartfile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "infobip/mobile-messaging-sdk-ios" "9.
|
|
1
|
+
github "infobip/mobile-messaging-sdk-ios" "9.2.7"
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "infobip/mobile-messaging-sdk-ios" "9.
|
|
1
|
+
github "infobip/mobile-messaging-sdk-ios" "9.2.7"
|
|
@@ -15,8 +15,8 @@ class RNMMChat: NSObject {
|
|
|
15
15
|
func showChat(presentingOptions: NSDictionary) {
|
|
16
16
|
var presentVCModally = false
|
|
17
17
|
if let presentingOptions = presentingOptions as? [String: Any],
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
let iosOptions = presentingOptions["ios"] as? [String: Any],
|
|
19
|
+
let shouldBePresentedModally = iosOptions["shouldBePresentedModally"] as? Bool {
|
|
20
20
|
presentVCModally = shouldBePresentedModally
|
|
21
21
|
}
|
|
22
22
|
let vc = presentVCModally ? MMChatViewController.makeRootNavigationViewController(): MMChatViewController.makeRootNavigationViewControllerWithCustomTransition()
|
|
@@ -30,10 +30,20 @@ class RNMMChat: NSObject {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
@objc(getMessageCounter:)
|
|
34
|
+
func getMessageCounter(onResult: @escaping RCTResponseSenderBlock) {
|
|
35
|
+
onResult([MobileMessaging.inAppChat?.getMessageCounter ?? 0])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@objc(resetMessageCounter)
|
|
39
|
+
func resetMessageCounter() {
|
|
40
|
+
MobileMessaging.inAppChat?.resetMessageCounter()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc(setupChatSettings:)
|
|
44
|
+
func setupChatSettings(settings: NSDictionary) {
|
|
45
|
+
if let chatSettings = settings as? [String: AnyObject] {
|
|
46
|
+
MobileMessaging.inAppChat?.settings.configureWith(rawConfig: chatSettings)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
@implementation RNMMChat (RCTExternModule)
|
|
18
18
|
RCT_EXPORT_MODULE_NO_LOAD(RNMMChat, RNMMChat)
|
|
19
19
|
RCT_EXTERN_METHOD(showChat:)
|
|
20
|
+
RCT_EXTERN_METHOD(getMessageCounter:(RCTResponseSenderBlock)resultCallback)
|
|
21
|
+
RCT_EXTERN_METHOD(resetMessageCounter)
|
|
20
22
|
RCT_EXTERN_METHOD(setupChatSettings:)
|
|
21
23
|
|
|
22
24
|
- (dispatch_queue_t)methodQueue {
|
|
@@ -31,7 +31,8 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
31
31
|
EventName.messageStorage_save,
|
|
32
32
|
EventName.messageStorage_find,
|
|
33
33
|
EventName.messageStorage_findAll,
|
|
34
|
-
EventName.inAppChat_availabilityUpdated
|
|
34
|
+
EventName.inAppChat_availabilityUpdated,
|
|
35
|
+
EventName.inAppChat_unreadMessageCounterUpdated
|
|
35
36
|
]
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -23,7 +23,8 @@ class RNMobileMessagingEventsManager {
|
|
|
23
23
|
EventName.personalized: MMNotificationPersonalized,
|
|
24
24
|
EventName.installationUpdated: MMNotificationInstallationSynced,
|
|
25
25
|
EventName.userUpdated: MMNotificationUserSynced,
|
|
26
|
-
EventName.inAppChat_availabilityUpdated: MMNotificationInAppChatAvailabilityUpdated
|
|
26
|
+
EventName.inAppChat_availabilityUpdated: MMNotificationInAppChatAvailabilityUpdated,
|
|
27
|
+
EventName.inAppChat_unreadMessageCounterUpdated: MMNotificationInAppChatUnreadMessagesCounterUpdated
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
func startObserving() {
|
|
@@ -110,6 +111,9 @@ class RNMobileMessagingEventsManager {
|
|
|
110
111
|
case MMNotificationInAppChatAvailabilityUpdated:
|
|
111
112
|
eventName = EventName.inAppChat_availabilityUpdated
|
|
112
113
|
notificationResult = notification.userInfo?[MMNotificationKeyInAppChatEnabled] as? Bool
|
|
114
|
+
case MMNotificationInAppChatUnreadMessagesCounterUpdated:
|
|
115
|
+
eventName = EventName.inAppChat_unreadMessageCounterUpdated
|
|
116
|
+
notificationResult = notification.userInfo?[MMNotificationKeyInAppChatUnreadMessagesCounter] as? Int
|
|
113
117
|
default: break
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -116,4 +116,5 @@ struct EventName {
|
|
|
116
116
|
static let messageStorage_find = "messageStorage.find"
|
|
117
117
|
static let messageStorage_findAll = "messageStorage.findAll"
|
|
118
118
|
static let inAppChat_availabilityUpdated = "inAppChat.availabilityUpdated"
|
|
119
|
+
static let inAppChat_unreadMessageCounterUpdated = "inAppChat.unreadMessageCounterUpdated"
|
|
119
120
|
}
|
package/package.json
CHANGED
|
Binary file
|