infobip-mobile-messaging-react-native-plugin 8.0.1 → 8.0.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 +4 -3
- package/android/gradle.properties +2 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatModule.java +6 -1
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactChatView.java +13 -40
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingModule.java +73 -63
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/Utils.java +3 -1
- package/infobip-mobile-messaging-react-native-plugin-8.0.1.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +3 -3
- package/ios/MobileMessagingPlugin/RNMMChat.swift +6 -1
- package/ios/MobileMessagingPlugin/RNMMChatBridge.m +1 -0
- package/ios/MobileMessagingPlugin/RNMMChatViewManager.swift +5 -5
- package/ios/MobileMessagingPlugin/RNMobileMessaging.swift +3 -2
- package/ios/MobileMessagingPlugin/RNMobileMessagingEventsManager.swift +7 -1
- package/ios/MobileMessagingPlugin/RNMobileMessagingUtils.swift +2 -0
- package/package.json +1 -1
- package/src/index.d.ts +9 -2
- package/src/index.js +10 -3
- package/infobip-mobile-messaging-react-native-plugin-8.0.0.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -85,13 +85,14 @@ repositories {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
dependencies {
|
|
88
|
-
def mmVersion = '
|
|
88
|
+
def mmVersion = '8.1.4'
|
|
89
89
|
|
|
90
90
|
implementation 'com.facebook.react:react-native:+'
|
|
91
91
|
implementation "androidx.annotation:annotation:1.1.0"
|
|
92
92
|
|
|
93
|
-
implementation 'com.google.android.material:material:1.
|
|
94
|
-
implementation 'androidx.exifinterface:exifinterface:1.3.
|
|
93
|
+
implementation 'com.google.android.material:material:1.8.0'
|
|
94
|
+
implementation 'androidx.exifinterface:exifinterface:1.3.6'
|
|
95
|
+
implementation 'androidx.databinding:viewbinding:8.0.1'
|
|
95
96
|
|
|
96
97
|
implementation "com.infobip:infobip-mobile-messaging-android-resources:$mmVersion@aar"
|
|
97
98
|
implementation "com.infobip:infobip-mobile-messaging-android-chat-sdk:$mmVersion@aar"
|
|
@@ -37,7 +37,12 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
|
|
|
37
37
|
|
|
38
38
|
@ReactMethod
|
|
39
39
|
public void showChat(ReadableMap args) {
|
|
40
|
-
InAppChat.getInstance(reactContext).
|
|
40
|
+
InAppChat.getInstance(reactContext).inAppChatScreen().show();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
public void showThreadsList() {
|
|
45
|
+
InAppChat.getInstance(reactContext).showThreadsList();
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
@ReactMethod
|
|
@@ -21,6 +21,7 @@ import androidx.fragment.app.FragmentActivity;
|
|
|
21
21
|
import androidx.fragment.app.FragmentManager;
|
|
22
22
|
import androidx.fragment.app.FragmentTransaction;
|
|
23
23
|
|
|
24
|
+
import org.infobip.mobile.messaging.chat.InAppChat;
|
|
24
25
|
import org.infobip.mobile.messaging.chat.view.InAppChatFragment;
|
|
25
26
|
|
|
26
27
|
class ReactChatView extends FrameLayout {
|
|
@@ -60,39 +61,19 @@ class ReactChatView extends FrameLayout {
|
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
InAppChatFragment.InAppChatActionBarProvider provider = new InAppChatFragment.InAppChatActionBarProvider() {
|
|
64
|
-
|
|
65
|
-
@Nullable
|
|
66
|
-
@Override
|
|
67
|
-
public ActionBar getOriginalSupportActionBar() {
|
|
68
|
-
if (fragmentActivity instanceof AppCompatActivity){
|
|
69
|
-
return ((AppCompatActivity) fragmentActivity).getSupportActionBar();
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@Override
|
|
75
|
-
public void onInAppChatBackPressed() {
|
|
76
|
-
if (fragmentActivity != null){
|
|
77
|
-
fragmentActivity.onBackPressed();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
64
|
//RN issue https://github.com/facebook/react-native/issues/17968
|
|
83
65
|
//Without this layout will not be called and view will not be displayed, because RN doesn't dispatches events to android views properly
|
|
84
66
|
ViewGroup parentView = (ViewGroup) parentLayout.findViewById(reactNativeViewId).getParent();
|
|
85
67
|
setupLayoutHack(parentView);
|
|
86
68
|
|
|
87
69
|
FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
70
|
+
InAppChat.getInstance(fragmentActivity.getApplicationContext()).showInAppChatFragment(fragmentManager, reactNativeViewId);
|
|
71
|
+
fragmentManager.executePendingTransactions();
|
|
72
|
+
Fragment inAppChatFragment = fragmentManager.findFragmentByTag(Utils.RN_IN_APP_CHAT_FRAGMENT_TAG);
|
|
73
|
+
Log.e(Utils.TAG, "InAppChatFragment found " + (inAppChatFragment != null));
|
|
74
|
+
if (inAppChatFragment instanceof InAppChatFragment){
|
|
75
|
+
((InAppChatFragment) inAppChatFragment).setWithToolbar(false);
|
|
94
76
|
}
|
|
95
|
-
fragmentTransaction.commit();
|
|
96
77
|
}
|
|
97
78
|
|
|
98
79
|
public void removeChatFragment(FrameLayout parentLayout, @Nullable FragmentActivity fragmentActivity) {
|
|
@@ -109,21 +90,13 @@ class ReactChatView extends FrameLayout {
|
|
|
109
90
|
}
|
|
110
91
|
|
|
111
92
|
private void setupLayoutHack(final ViewGroup view) {
|
|
112
|
-
view.getViewTreeObserver().addOnGlobalLayoutListener(
|
|
113
|
-
@Override
|
|
114
|
-
public void onGlobalLayout() {
|
|
115
|
-
view.requestLayout();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
93
|
+
view.getViewTreeObserver().addOnGlobalLayoutListener(view::requestLayout);
|
|
118
94
|
}
|
|
119
95
|
|
|
120
|
-
private final Runnable measureAndLayout =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
126
|
-
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
127
|
-
}
|
|
96
|
+
private final Runnable measureAndLayout = () -> {
|
|
97
|
+
measure(
|
|
98
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
99
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
100
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
128
101
|
};
|
|
129
102
|
}
|
|
@@ -143,6 +143,8 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
143
143
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
//region BroadcastReceivers
|
|
147
|
+
//region Events
|
|
146
148
|
private static final String EVENT_TOKEN_RECEIVED = "tokenReceived";
|
|
147
149
|
private static final String EVENT_REGISTRATION_UPDATED = "registrationUpdated";
|
|
148
150
|
private static final String EVENT_INSTALLATION_UPDATED = "installationUpdated";
|
|
@@ -154,31 +156,26 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
154
156
|
private static final String EVENT_NOTIFICATION_TAPPED = "notificationTapped";
|
|
155
157
|
private static final String EVENT_NOTIFICATION_ACTION_TAPPED = "actionTapped";
|
|
156
158
|
private static final String EVENT_MESSAGE_RECEIVED = "messageReceived";
|
|
157
|
-
private static final String EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED = "inAppChat.unreadMessageCounterUpdated";
|
|
158
159
|
|
|
159
|
-
private static final
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
put(Event.INSTALLATION_UPDATED.getKey(), EVENT_INSTALLATION_UPDATED);
|
|
163
|
-
put(Event.USER_UPDATED.getKey(), EVENT_USER_UPDATED);
|
|
164
|
-
put(Event.PERSONALIZED.getKey(), EVENT_PERSONALIZED);
|
|
165
|
-
put(Event.DEPERSONALIZED.getKey(), EVENT_DEPERSONALIZED);
|
|
166
|
-
put(GeoEvent.GEOFENCE_AREA_ENTERED.getKey(), EVENT_GEOFENCE_ENTERED);
|
|
167
|
-
}};
|
|
168
|
-
|
|
169
|
-
private static final Map<String, String> messageBroadcastEventMap = new HashMap<String, String>() {{
|
|
170
|
-
put(Event.MESSAGE_RECEIVED.getKey(), EVENT_MESSAGE_RECEIVED);
|
|
171
|
-
put(Event.NOTIFICATION_TAPPED.getKey(), EVENT_NOTIFICATION_TAPPED);
|
|
172
|
-
put(InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey(), EVENT_NOTIFICATION_ACTION_TAPPED);
|
|
173
|
-
put(InAppChatEvent.UNREAD_MESSAGES_COUNTER_UPDATED.getKey(), EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED);
|
|
174
|
-
}};
|
|
160
|
+
private static final String EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED = "inAppChat.unreadMessageCounterUpdated";
|
|
161
|
+
private static final String EVENT_INAPPCHAT_VIEW_STATE_CHANGED = "inAppChat.viewStateChanged";
|
|
162
|
+
//endregion
|
|
175
163
|
|
|
164
|
+
//region MessageStorageBroadcastReceiver
|
|
176
165
|
private static final Map<String, String> messageStorageEventMap = new HashMap<String, String>() {{
|
|
177
166
|
put(MessageStoreAdapter.EVENT_MESSAGESTORAGE_START, MessageStoreAdapter.EVENT_MESSAGESTORAGE_START);
|
|
178
167
|
put(MessageStoreAdapter.EVENT_MESSAGESTORAGE_SAVE, MessageStoreAdapter.EVENT_MESSAGESTORAGE_SAVE);
|
|
179
168
|
put(MessageStoreAdapter.EVENT_MESSAGESTORAGE_FIND_ALL, MessageStoreAdapter.EVENT_MESSAGESTORAGE_FIND_ALL);
|
|
180
169
|
}};
|
|
181
170
|
|
|
171
|
+
private static String getMessageStorageBroadcastEvent(Intent intent) {
|
|
172
|
+
if (intent == null || intent.getAction() == null) {
|
|
173
|
+
Log.w(Utils.TAG, "Cannot process event for broadcast, cause intent or action is null");
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return messageStorageEventMap.get(intent.getAction());
|
|
177
|
+
}
|
|
178
|
+
|
|
182
179
|
private final BroadcastReceiver messageStorageReceiver = new BroadcastReceiver() {
|
|
183
180
|
@Override
|
|
184
181
|
public void onReceive(Context context, Intent intent) {
|
|
@@ -206,6 +203,19 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
206
203
|
}
|
|
207
204
|
}
|
|
208
205
|
};
|
|
206
|
+
//endregion
|
|
207
|
+
|
|
208
|
+
//region MessageBroadcastReceiver
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* For event caching, if plugin not yet initialized
|
|
212
|
+
*/
|
|
213
|
+
private static final Map<String, String> messageBroadcastEventMap = new HashMap<String, String>() {{
|
|
214
|
+
put(Event.MESSAGE_RECEIVED.getKey(), EVENT_MESSAGE_RECEIVED);
|
|
215
|
+
put(Event.NOTIFICATION_TAPPED.getKey(), EVENT_NOTIFICATION_TAPPED);
|
|
216
|
+
put(InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey(), EVENT_NOTIFICATION_ACTION_TAPPED);
|
|
217
|
+
put(InAppChatEvent.UNREAD_MESSAGES_COUNTER_UPDATED.getKey(), EVENT_INAPPCHAT_UNREAD_MESSAGES_COUNT_UPDATED);
|
|
218
|
+
}};
|
|
209
219
|
|
|
210
220
|
private static String getMessageBroadcastEvent(Intent intent) {
|
|
211
221
|
if (intent == null || intent.getAction() == null) {
|
|
@@ -215,18 +225,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
215
225
|
return messageBroadcastEventMap.get(intent.getAction());
|
|
216
226
|
}
|
|
217
227
|
|
|
218
|
-
private static String getMessageStorageBroadcastEvent(Intent intent) {
|
|
219
|
-
if (intent == null || intent.getAction() == null) {
|
|
220
|
-
Log.w(Utils.TAG, "Cannot process event for broadcast, cause intent or action is null");
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
return messageStorageEventMap.get(intent.getAction());
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/*
|
|
227
|
-
For event caching, if plugin not yet initialized
|
|
228
|
-
*/
|
|
229
|
-
|
|
230
228
|
public static class MessageEventReceiver extends BroadcastReceiver {
|
|
231
229
|
@Override
|
|
232
230
|
public void onReceive(Context context, Intent intent) {
|
|
@@ -272,6 +270,19 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
272
270
|
return reactApplication.getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
|
|
273
271
|
}
|
|
274
272
|
}
|
|
273
|
+
//endregion
|
|
274
|
+
|
|
275
|
+
//region CommonLibraryEventsBroadcastReceiver
|
|
276
|
+
private static final Map<String, String> broadcastEventMap = new HashMap<String, String>() {{
|
|
277
|
+
put(Event.TOKEN_RECEIVED.getKey(), EVENT_TOKEN_RECEIVED);
|
|
278
|
+
put(Event.REGISTRATION_CREATED.getKey(), EVENT_REGISTRATION_UPDATED);
|
|
279
|
+
put(Event.INSTALLATION_UPDATED.getKey(), EVENT_INSTALLATION_UPDATED);
|
|
280
|
+
put(Event.USER_UPDATED.getKey(), EVENT_USER_UPDATED);
|
|
281
|
+
put(Event.PERSONALIZED.getKey(), EVENT_PERSONALIZED);
|
|
282
|
+
put(Event.DEPERSONALIZED.getKey(), EVENT_DEPERSONALIZED);
|
|
283
|
+
put(GeoEvent.GEOFENCE_AREA_ENTERED.getKey(), EVENT_GEOFENCE_ENTERED);
|
|
284
|
+
put(InAppChatEvent.CHAT_VIEW_CHANGED.getKey(), EVENT_INAPPCHAT_VIEW_STATE_CHANGED);
|
|
285
|
+
}};
|
|
275
286
|
|
|
276
287
|
private final BroadcastReceiver commonLibraryBroadcastReceiver = new BroadcastReceiver() {
|
|
277
288
|
@Override
|
|
@@ -312,6 +323,8 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
312
323
|
data = intent.getStringExtra(BroadcastParameter.EXTRA_CLOUD_TOKEN);
|
|
313
324
|
} else if (Event.REGISTRATION_CREATED.getKey().equals(intent.getAction())) {
|
|
314
325
|
data = intent.getStringExtra(BroadcastParameter.EXTRA_INFOBIP_ID);
|
|
326
|
+
} else if (InAppChatEvent.CHAT_VIEW_CHANGED.getKey().equals(intent.getAction())) {
|
|
327
|
+
data = intent.getStringExtra(BroadcastParameter.EXTRA_CHAT_VIEW);
|
|
315
328
|
}
|
|
316
329
|
|
|
317
330
|
if (data == null) {
|
|
@@ -321,6 +334,37 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
321
334
|
}
|
|
322
335
|
}
|
|
323
336
|
};
|
|
337
|
+
//endregion
|
|
338
|
+
|
|
339
|
+
private void registerBroadcastReceiver() {
|
|
340
|
+
|
|
341
|
+
IntentFilter commonLibIntentFilter = new IntentFilter();
|
|
342
|
+
for (String action : broadcastEventMap.keySet()) {
|
|
343
|
+
commonLibIntentFilter.addAction(action);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
reactContext.registerReceiver(commonLibraryBroadcastReceiver, commonLibIntentFilter);
|
|
347
|
+
|
|
348
|
+
IntentFilter messageStorageIntentFilter = new IntentFilter();
|
|
349
|
+
for (String action : messageStorageEventMap.keySet()) {
|
|
350
|
+
messageStorageIntentFilter.addAction(action);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
LocalBroadcastManager.getInstance(reactContext).registerReceiver(messageStorageReceiver, messageStorageIntentFilter);
|
|
354
|
+
broadcastReceiverRegistered = true;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private void unregisterBroadcastReceiver() {
|
|
358
|
+
if (!broadcastReceiverRegistered) return;
|
|
359
|
+
try {
|
|
360
|
+
reactContext.unregisterReceiver(commonLibraryBroadcastReceiver);
|
|
361
|
+
LocalBroadcastManager.getInstance(reactContext).unregisterReceiver(messageStorageReceiver);
|
|
362
|
+
} catch (IllegalArgumentException e) {
|
|
363
|
+
Log.d(Utils.TAG, "Can't unregister broadcast receivers");
|
|
364
|
+
}
|
|
365
|
+
broadcastReceiverRegistered = false;
|
|
366
|
+
}
|
|
367
|
+
//endregion
|
|
324
368
|
|
|
325
369
|
@ReactMethod
|
|
326
370
|
public void init(ReadableMap args, final Callback successCallback, final Callback errorCallback) throws JSONException {
|
|
@@ -419,40 +463,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
419
463
|
}
|
|
420
464
|
}
|
|
421
465
|
|
|
422
|
-
private void registerBroadcastReceiver() {
|
|
423
|
-
|
|
424
|
-
IntentFilter commonLibIntentFilter = new IntentFilter();
|
|
425
|
-
for (String action : broadcastEventMap.keySet()) {
|
|
426
|
-
commonLibIntentFilter.addAction(action);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
reactContext.registerReceiver(commonLibraryBroadcastReceiver, commonLibIntentFilter);
|
|
430
|
-
|
|
431
|
-
IntentFilter messageActionIntentFilter = new IntentFilter();
|
|
432
|
-
for (String action : messageBroadcastEventMap.keySet()) {
|
|
433
|
-
messageActionIntentFilter.addAction(action);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
IntentFilter messageStorageIntentFilter = new IntentFilter();
|
|
437
|
-
for (String action : messageStorageEventMap.keySet()) {
|
|
438
|
-
messageStorageIntentFilter.addAction(action);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
LocalBroadcastManager.getInstance(reactContext).registerReceiver(messageStorageReceiver, messageStorageIntentFilter);
|
|
442
|
-
broadcastReceiverRegistered = true;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
private void unregisterBroadcastReceiver() {
|
|
446
|
-
if (!broadcastReceiverRegistered) return;
|
|
447
|
-
try {
|
|
448
|
-
reactContext.unregisterReceiver(commonLibraryBroadcastReceiver);
|
|
449
|
-
LocalBroadcastManager.getInstance(reactContext).unregisterReceiver(messageStorageReceiver);
|
|
450
|
-
} catch (IllegalArgumentException e) {
|
|
451
|
-
Log.d(Utils.TAG, "Can't unregister broadcast receivers");
|
|
452
|
-
}
|
|
453
|
-
broadcastReceiverRegistered = false;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
466
|
/**
|
|
457
467
|
* Converts notification categories in configuration into library format
|
|
458
468
|
*
|
|
@@ -13,9 +13,11 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
13
13
|
import com.facebook.react.bridge.WritableMap;
|
|
14
14
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
15
15
|
|
|
16
|
+
import org.infobip.mobile.messaging.chat.view.InAppChatFragment;
|
|
17
|
+
|
|
16
18
|
public class Utils {
|
|
17
19
|
public static final String TAG = "RNMobileMessaging";
|
|
18
|
-
public static final String RN_IN_APP_CHAT_FRAGMENT_TAG =
|
|
20
|
+
public static final String RN_IN_APP_CHAT_FRAGMENT_TAG = InAppChatFragment.class.getName();
|
|
19
21
|
public static final int REQ_CODE_RESOLVE_GOOGLE_ERROR = 2;
|
|
20
22
|
|
|
21
23
|
/**
|
|
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", "10.
|
|
23
|
-
s.dependency "MobileMessaging/Geofencing", "10.
|
|
24
|
-
s.dependency "MobileMessaging/InAppChat", "10.
|
|
22
|
+
s.dependency "MobileMessaging/Core", "10.16.0"
|
|
23
|
+
s.dependency "MobileMessaging/Geofencing", "10.16.0"
|
|
24
|
+
s.dependency "MobileMessaging/InAppChat", "10.16.0"
|
|
25
25
|
|
|
26
26
|
end
|
|
@@ -30,6 +30,11 @@ class RNMMChat: NSObject {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
@objc(showThreadsList)
|
|
34
|
+
func showThreadsList() {
|
|
35
|
+
RNMMChatView.viewController?.showThreadsList()
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
@objc(getMessageCounter:)
|
|
34
39
|
func getMessageCounter(onResult: @escaping RCTResponseSenderBlock) {
|
|
35
40
|
onResult([MobileMessaging.inAppChat?.getMessageCounter ?? 0])
|
|
@@ -54,7 +59,7 @@ class RNMMChat: NSObject {
|
|
|
54
59
|
|
|
55
60
|
@objc(sendContextualData:multiThreadStrategy:onSuccess:onError:)
|
|
56
61
|
func sendContextualData(data: NSString, multiThreadStrategy: Bool, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
57
|
-
guard let chatVC =
|
|
62
|
+
guard let chatVC = RNMMChatView.viewController else {
|
|
58
63
|
return
|
|
59
64
|
}
|
|
60
65
|
chatVC.sendContextualData(String(data), multiThreadStrategy: multiThreadStrategy ? .ALL : .ACTIVE) { error in
|
|
@@ -22,6 +22,7 @@ RCT_EXTERN_METHOD(resetMessageCounter)
|
|
|
22
22
|
RCT_EXTERN_METHOD(setupChatSettings:)
|
|
23
23
|
RCT_EXTERN_METHOD(setLanguage:)
|
|
24
24
|
RCT_EXTERN_METHOD(sendContextualData:(NSString *)data multiThreadStrategy:(BOOL)multiThreadStrategy onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
25
|
+
RCT_EXTERN_METHOD(showThreadsList)
|
|
25
26
|
|
|
26
27
|
- (dispatch_queue_t)methodQueue {
|
|
27
28
|
return dispatch_get_main_queue();
|
|
@@ -24,7 +24,7 @@ class RNMMChatViewManager: RCTViewManager {
|
|
|
24
24
|
fatalError("init(coder:) has not been implemented")
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
weak var viewController: MMChatViewController?
|
|
27
|
+
weak static var viewController: MMChatViewController?
|
|
28
28
|
|
|
29
29
|
@objc func setSendButtonColor(_ colorString: NSString) {
|
|
30
30
|
MobileMessaging.inAppChat?.settings.configureWith(rawConfig: ["sendButtonColor": colorString])
|
|
@@ -32,7 +32,7 @@ class RNMMChatViewManager: RCTViewManager {
|
|
|
32
32
|
|
|
33
33
|
override func layoutSubviews() {
|
|
34
34
|
super.layoutSubviews()
|
|
35
|
-
viewController?.view.frame = bounds
|
|
35
|
+
RNMMChatView.viewController?.view.frame = bounds
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
override func didMoveToWindow() {
|
|
@@ -41,7 +41,7 @@ class RNMMChatViewManager: RCTViewManager {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
override func removeFromSuperview() {
|
|
44
|
-
|
|
44
|
+
RNMMChatView.viewController?.removeFromParent()
|
|
45
45
|
super.removeFromSuperview()
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -54,11 +54,11 @@ class RNMMChatViewManager: RCTViewManager {
|
|
|
54
54
|
parentVC.addChild(newChatVC)
|
|
55
55
|
addSubview(newChatVC.view)
|
|
56
56
|
newChatVC.didMove(toParent: parentVC)
|
|
57
|
-
|
|
57
|
+
RNMMChatView.viewController = newChatVC
|
|
58
58
|
return
|
|
59
59
|
}
|
|
60
60
|
/* existingChatVC is the case of didMoveToWindow being triggered from the presentation of other view (ie RTCImageView) */
|
|
61
|
-
|
|
61
|
+
RNMMChatView.viewController = existingChatVC
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -37,7 +37,8 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
37
37
|
EventName.messageStorage_find,
|
|
38
38
|
EventName.messageStorage_findAll,
|
|
39
39
|
EventName.inAppChat_availabilityUpdated,
|
|
40
|
-
EventName.inAppChat_unreadMessageCounterUpdated
|
|
40
|
+
EventName.inAppChat_unreadMessageCounterUpdated,
|
|
41
|
+
EventName.inAppChat_viewStateChanged
|
|
41
42
|
]
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -232,7 +233,7 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
232
233
|
}
|
|
233
234
|
})
|
|
234
235
|
}
|
|
235
|
-
|
|
236
|
+
|
|
236
237
|
@objc(personalize:onSuccess:onError:)
|
|
237
238
|
func personalize(context: NSDictionary, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
238
239
|
guard let context = context as? [String: Any], let uiDict = context["userIdentity"] as? [String: Any] else
|
|
@@ -25,7 +25,8 @@ class RNMobileMessagingEventsManager {
|
|
|
25
25
|
EventName.installationUpdated: MMNotificationInstallationSynced,
|
|
26
26
|
EventName.userUpdated: MMNotificationUserSynced,
|
|
27
27
|
EventName.inAppChat_availabilityUpdated: MMNotificationInAppChatAvailabilityUpdated,
|
|
28
|
-
EventName.inAppChat_unreadMessageCounterUpdated: MMNotificationInAppChatUnreadMessagesCounterUpdated
|
|
28
|
+
EventName.inAppChat_unreadMessageCounterUpdated: MMNotificationInAppChatUnreadMessagesCounterUpdated,
|
|
29
|
+
EventName.inAppChat_viewStateChanged: MMNotificationInAppChatViewChanged
|
|
29
30
|
]
|
|
30
31
|
|
|
31
32
|
func startObserving() {
|
|
@@ -121,6 +122,11 @@ class RNMobileMessagingEventsManager {
|
|
|
121
122
|
case MMNotificationInAppChatUnreadMessagesCounterUpdated:
|
|
122
123
|
eventName = EventName.inAppChat_unreadMessageCounterUpdated
|
|
123
124
|
notificationResult = notification.userInfo?[MMNotificationKeyInAppChatUnreadMessagesCounter] as? Int
|
|
125
|
+
case MMNotificationInAppChatViewChanged:
|
|
126
|
+
eventName = EventName.inAppChat_viewStateChanged
|
|
127
|
+
if let viewState = notification.userInfo?[MMNotificationKeyInAppChatViewChanged] as? String {
|
|
128
|
+
notificationResult = viewState
|
|
129
|
+
}
|
|
124
130
|
default: break
|
|
125
131
|
}
|
|
126
132
|
|
|
@@ -117,6 +117,8 @@ struct EventName {
|
|
|
117
117
|
static let messageStorage_findAll = "messageStorage.findAll"
|
|
118
118
|
static let inAppChat_availabilityUpdated = "inAppChat.availabilityUpdated"
|
|
119
119
|
static let inAppChat_unreadMessageCounterUpdated = "inAppChat.unreadMessageCounterUpdated"
|
|
120
|
+
static let inAppChat_viewStateChanged = "inAppChat.viewStateChanged"
|
|
121
|
+
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
extension UIApplication {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infobip-mobile-messaging-react-native-plugin",
|
|
3
3
|
"title": "Infobip Mobile Messaging React Native Plugin",
|
|
4
|
-
"version": "8.0.
|
|
4
|
+
"version": "8.0.2",
|
|
5
5
|
"description": "Infobip Mobile Messaging React Native Plugin",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"scripts": {
|
package/src/index.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ declare namespace MobileMessagingReactNative {
|
|
|
15
15
|
'depersonalized' |
|
|
16
16
|
'inAppChat.availabilityUpdated' |
|
|
17
17
|
'inAppChat.unreadMessageCounterUpdated' |
|
|
18
|
-
'deeplink'
|
|
18
|
+
'deeplink' |
|
|
19
|
+
'inAppChat.viewStateChanged';
|
|
19
20
|
|
|
20
21
|
export interface Configuration {
|
|
21
22
|
/**
|
|
@@ -229,7 +230,8 @@ declare namespace MobileMessagingReactNative {
|
|
|
229
230
|
|
|
230
231
|
inAppChatEvents: [
|
|
231
232
|
"inAppChat.availabilityUpdated",
|
|
232
|
-
"inAppChat.unreadMessageCounterUpdated"
|
|
233
|
+
"inAppChat.unreadMessageCounterUpdated",
|
|
234
|
+
"inAppChat.viewStateChanged"
|
|
233
235
|
];
|
|
234
236
|
|
|
235
237
|
supportedEvents: [
|
|
@@ -490,6 +492,11 @@ declare namespace MobileMessagingReactNative {
|
|
|
490
492
|
*/
|
|
491
493
|
resetMessageCounter(): void;
|
|
492
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Navigates to THREAD_LIST view in multithread widget if in-app chat is shown as React Component.
|
|
497
|
+
*/
|
|
498
|
+
showThreadsList(): void;
|
|
499
|
+
|
|
493
500
|
/**
|
|
494
501
|
* This is used for requesting Location permissions for Android
|
|
495
502
|
* @param rationale rationale to display if it's needed. Describing why this permissions required.
|
package/src/index.js
CHANGED
|
@@ -37,12 +37,11 @@ class MobileMessaging {
|
|
|
37
37
|
'messageStorage.find',
|
|
38
38
|
'messageStorage.findAll'
|
|
39
39
|
];
|
|
40
|
-
|
|
41
40
|
this.inAppChatEvents = [
|
|
42
41
|
'inAppChat.availabilityUpdated',
|
|
43
|
-
'inAppChat.unreadMessageCounterUpdated'
|
|
42
|
+
'inAppChat.unreadMessageCounterUpdated',
|
|
43
|
+
'inAppChat.viewStateChanged'
|
|
44
44
|
];
|
|
45
|
-
|
|
46
45
|
this.eventEmitter = new NativeEventEmitter(ReactNativeMobileMessaging);
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -578,6 +577,14 @@ class MobileMessaging {
|
|
|
578
577
|
RNMMChat.resetMessageCounter();
|
|
579
578
|
};
|
|
580
579
|
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Navigates to THREAD_LIST view in multithread widget if in-app chat is shown as React Component.
|
|
583
|
+
*/
|
|
584
|
+
showThreadsList() {
|
|
585
|
+
RNMMChat.showThreadsList();
|
|
586
|
+
};
|
|
587
|
+
|
|
581
588
|
/**
|
|
582
589
|
* Registering for POST_NOTIFICATIONS permission for Android 13+
|
|
583
590
|
*/
|
|
Binary file
|