infobip-mobile-messaging-react-native-plugin 13.8.0 → 13.8.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.
@@ -221,16 +221,6 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
221
221
  }
222
222
  }
223
223
 
224
- @ReactMethod
225
- public void setupChatSettings(ReadableMap settings) throws JSONException {
226
- Configuration.InAppChatCustomization inAppChatCustomization = Configuration.resolveChatSettings(ReactNativeJson.convertMapToJson(settings));
227
- InAppChat inAppChat = InAppChat.getInstance(reactContext);
228
- inAppChat.setTheme(createTheme(inAppChatCustomization));
229
- if (inAppChatCustomization.widgetTheme != null) {
230
- inAppChat.setWidgetTheme(inAppChatCustomization.widgetTheme);
231
- }
232
- }
233
-
234
224
  @ReactMethod
235
225
  public void setWidgetTheme(String widgetTheme) {
236
226
  if (widgetTheme != null) {
@@ -456,6 +456,13 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
456
456
  if (configuration.android.firebaseOptions != null) {
457
457
  builder.withFirebaseOptions(configuration.android.firebaseOptions);
458
458
  }
459
+
460
+ String notificationChannelId = configuration.android.notificationChannelId;
461
+ String notificationChannelName = configuration.android.notificationChannelName;
462
+ String notificationSound = configuration.android.notificationSound;
463
+ if (notificationChannelId != null && notificationChannelName != null && notificationSound != null) {
464
+ builder.withCustomNotificationChannel(notificationChannelId, notificationChannelName, notificationSound);
465
+ }
459
466
  }
460
467
 
461
468
  if (configuration.userDataJwt != null) {
@@ -57,89 +57,37 @@ class RNMMChat: NSObject {
57
57
  @objc(setChatCustomization:)
58
58
  func setChatCustomization(settings: NSDictionary) {
59
59
  guard let settings = settings as? [String: AnyObject] else { return }
60
- let chatsettings = MMChatSettings.sharedInstance
61
- if let chatToolbar = ChatCustomizationKeys.chatToolbar.getDict(from: settings) {
62
- setNotNil(&chatsettings.navBarColor, ToolbarCustomizationKeys.backgroundColor.getColor(from: chatToolbar))
63
- setNotNil(&chatsettings.navBarTitleColor, ToolbarCustomizationKeys.titleTextColor.getColor(from: chatToolbar))
64
- setNotNil(&chatsettings.title, ToolbarCustomizationKeys.titleText.getString(from: chatToolbar))
65
- setNotNil(&chatsettings.navBarItemsTintColor, ToolbarCustomizationKeys.navigationIconTint.getColor(from: chatToolbar))
66
- }
67
- if let attachmentPreviewToolbar = ChatCustomizationKeys.attachmentPreviewToolbar.getDict(from: settings) {
68
- setNotNil(&chatsettings.attachmentPreviewBarsColor, ToolbarCustomizationKeys.backgroundColor.getColor(from: attachmentPreviewToolbar))
69
- setNotNil(&chatsettings.attachmentPreviewItemsColor, ToolbarCustomizationKeys.navigationIconTint.getColor(from: attachmentPreviewToolbar))
70
- }
71
- setNotNil(&chatsettings.backgroundColor, ChatCustomizationKeys.chatBackgroundColor.getColor(from: settings))
72
- setNotNil(&chatsettings.advancedSettings.mainTextColor, ChatCustomizationKeys.chatInputTextColor.getColor(from: settings))
73
- setNotNil(&chatsettings.advancedSettings.textInputBackgroundColor, ChatCustomizationKeys.chatInputBackgroundColor.getColor(from: settings))
74
- setNotNil(&chatsettings.advancedSettings.attachmentButtonIcon,
75
- ChatCustomizationKeys.chatInputAttachmentIcon.getImage(from: settings))
76
- setNotNil(&chatsettings.advancedSettings.sendButtonIcon,
77
- ChatCustomizationKeys.chatInputSendIcon.getImage(from: settings))
78
- setNotNil(&chatsettings.sendButtonTintColor, ChatCustomizationKeys.chatInputSendIconTint.getColor(from: settings))
79
- setNotNil(&chatsettings.chatInputSeparatorLineColor, ChatCustomizationKeys.chatInputSeparatorLineColor.getColor(from: settings))
80
- setNotNil(&chatsettings.advancedSettings.isLineSeparatorHidden, ChatCustomizationKeys.chatInputSeparatorLineVisible.getBool(from: settings))
81
- setNotNil(&chatsettings.advancedSettings.typingIndicatorColor, ChatCustomizationKeys.chatInputCursorColor.getColor(from: settings))
82
- setNotNil(&chatsettings.errorLabelTextColor, ChatCustomizationKeys.networkErrorTextColor.getColor(from: settings))
83
- setNotNil(&chatsettings.errorLabelBackgroundColor, ChatCustomizationKeys.networkErrorLabelBackgroundColor.getColor(from: settings))
84
- setNotNil(&chatsettings.advancedSettings.mainPlaceholderTextColor, ChatCustomizationKeys.chatInputHintTextColor.getColor(from: settings))
85
- func setNotNil<T>(_ forVariable: inout T, _ value:T?) {
86
- if let value = value { forVariable = value }
60
+ Task { [weak self] in
61
+ let chatsettings = MMChatSettings.sharedInstance
62
+ if let chatToolbar = ChatCustomizationKeys.chatToolbar.getDict(from: settings) {
63
+ self?.setNotNil(&chatsettings.navBarColor, ToolbarCustomizationKeys.backgroundColor.getColor(from: chatToolbar))
64
+ self?.setNotNil(&chatsettings.navBarTitleColor, ToolbarCustomizationKeys.titleTextColor.getColor(from: chatToolbar))
65
+ self?.setNotNil(&chatsettings.title, ToolbarCustomizationKeys.titleText.getString(from: chatToolbar))
66
+ self?.setNotNil(&chatsettings.navBarItemsTintColor, ToolbarCustomizationKeys.navigationIconTint.getColor(from: chatToolbar))
67
+ }
68
+ if let attachmentPreviewToolbar = ChatCustomizationKeys.attachmentPreviewToolbar.getDict(from: settings) {
69
+ self?.setNotNil(&chatsettings.attachmentPreviewBarsColor, ToolbarCustomizationKeys.backgroundColor.getColor(from: attachmentPreviewToolbar))
70
+ self?.setNotNil(&chatsettings.attachmentPreviewItemsColor, ToolbarCustomizationKeys.navigationIconTint.getColor(from: attachmentPreviewToolbar))
71
+ }
72
+ self?.setNotNil(&chatsettings.backgroundColor, ChatCustomizationKeys.chatBackgroundColor.getColor(from: settings))
73
+ self?.setNotNil(&chatsettings.advancedSettings.mainTextColor, ChatCustomizationKeys.chatInputTextColor.getColor(from: settings))
74
+ self?.setNotNil(&chatsettings.advancedSettings.textInputBackgroundColor, ChatCustomizationKeys.chatInputBackgroundColor.getColor(from: settings))
75
+ self?.setNotNil(&chatsettings.advancedSettings.attachmentButtonIcon,
76
+ ChatCustomizationKeys.chatInputAttachmentIcon.getImage(from: settings))
77
+ self?.setNotNil(&chatsettings.advancedSettings.sendButtonIcon,
78
+ ChatCustomizationKeys.chatInputSendIcon.getImage(from: settings))
79
+ self?.setNotNil(&chatsettings.sendButtonTintColor, ChatCustomizationKeys.chatInputSendIconTint.getColor(from: settings))
80
+ self?.setNotNil(&chatsettings.chatInputSeparatorLineColor, ChatCustomizationKeys.chatInputSeparatorLineColor.getColor(from: settings))
81
+ self?.setNotNil(&chatsettings.advancedSettings.isLineSeparatorHidden, ChatCustomizationKeys.chatInputSeparatorLineVisible.getBool(from: settings))
82
+ self?.setNotNil(&chatsettings.advancedSettings.typingIndicatorColor, ChatCustomizationKeys.chatInputCursorColor.getColor(from: settings))
83
+ self?.setNotNil(&chatsettings.errorLabelTextColor, ChatCustomizationKeys.networkErrorTextColor.getColor(from: settings))
84
+ self?.setNotNil(&chatsettings.errorLabelBackgroundColor, ChatCustomizationKeys.networkErrorLabelBackgroundColor.getColor(from: settings))
85
+ self?.setNotNil(&chatsettings.advancedSettings.mainPlaceholderTextColor, ChatCustomizationKeys.chatInputHintTextColor.getColor(from: settings))
87
86
  }
88
87
  }
89
-
90
- @objc(setupChatSettings:)
91
- func setupChatSettings(settings: NSDictionary) {
92
- guard let settings = settings as? [String: AnyObject] else { return }
93
- let chatSettings = MMChatSettings.sharedInstance
94
-
95
- setNotNil(&chatSettings.title, CustomizationKeys.toolbarTitle.getString(from: settings))
96
- /// Colors
97
- setNotNil(&chatSettings.navBarItemsTintColor, CustomizationKeys.toolbarTintColor.getColor(from: settings))
98
- setNotNil(&chatSettings.navBarColor, CustomizationKeys.toolbarBackgroundColor.getColor(from: settings))
99
- setNotNil(&chatSettings.navBarTitleColor, CustomizationKeys.toolbarTitleColor.getColor(from: settings))
100
- setNotNil(&chatSettings.advancedSettings.mainTextColor, CustomizationKeys.inputTextColor.getColor(from: settings))
101
88
 
102
- setNotNil(&chatSettings.sendButtonTintColor, CustomizationKeys.sendButtonTintColor.getColor(from: settings))
103
- setNotNil(&chatSettings.backgroundColor, CustomizationKeys.chatBackgroundColor.getColor(from: settings))
104
- setNotNil(&chatSettings.errorLabelTextColor, CustomizationKeys.noConnectionAlertTextColor.getColor(from: settings))
105
- setNotNil(&chatSettings.errorLabelBackgroundColor, CustomizationKeys.noConnectionAlertBackgroundColor.getColor(from: settings))
106
- setNotNil(&chatSettings.widgetTheme, CustomizationKeys.widgetTheme.getString(from: settings))
107
-
108
- setNotNil(&chatSettings.advancedSettings.mainPlaceholderTextColor, CustomizationKeys.chatInputPlaceholderTextColor.getColor(from: settings))
109
- setNotNil(&chatSettings.advancedSettings.typingIndicatorColor, CustomizationKeys.chatInputCursorColor.getColor(from: settings))
110
- /// Icons
111
- setNotNil(&chatSettings.advancedSettings.sendButtonIcon, CustomizationKeys.sendButtonIcon.getImage(from: settings))
112
- setNotNil(&chatSettings.advancedSettings.attachmentButtonIcon, CustomizationKeys.attachmentButtonIcon.getImage(from: settings))
113
- /// Attachment colors
114
- setNotNil(&chatSettings.attachmentPreviewBarsColor, CustomizationKeys.attachmentPreviewBarsColor.getColor(from: settings))
115
- setNotNil(&chatSettings.attachmentPreviewItemsColor, CustomizationKeys.attachmentPreviewItemsColor.getColor(from: settings))
116
-
117
- if let chatInputSeparatorVisible = CustomizationKeys.chatInputSeparatorVisible.getBool(from: settings) {
118
- chatSettings.advancedSettings.isLineSeparatorHidden = !chatInputSeparatorVisible
119
- }
120
- /// Sizes
121
- setNotNil(&chatSettings.advancedSettings.textContainerTopMargin, CustomizationKeys.textContainerTopMargin.getCGFloat(from: settings))
122
- setNotNil(&chatSettings.advancedSettings.textContainerLeftPadding, CustomizationKeys.textContainerLeftPadding.getCGFloat(from: settings))
123
- setNotNil(&chatSettings.advancedSettings.textContainerCornerRadius, CustomizationKeys.textContainerCornerRadius.getCGFloat(from: settings))
124
- setNotNil(&chatSettings.advancedSettings.textViewTopMargin, CustomizationKeys.textViewTopMargin.getCGFloat(from: settings))
125
- setNotNil(&chatSettings.advancedSettings.placeholderHeight, CustomizationKeys.placeholderHeight.getCGFloat(from: settings))
126
- setNotNil(&chatSettings.advancedSettings.placeholderSideMargin, CustomizationKeys.placeholderSideMargin.getCGFloat(from: settings))
127
- setNotNil(&chatSettings.advancedSettings.buttonHeight, CustomizationKeys.buttonHeight.getCGFloat(from: settings))
128
- setNotNil(&chatSettings.advancedSettings.buttonTouchableOverlap, CustomizationKeys.buttonTouchableOverlap.getCGFloat(from: settings))
129
- setNotNil(&chatSettings.advancedSettings.buttonRightMargin, CustomizationKeys.buttonRightMargin.getCGFloat(from: settings))
130
- setNotNil(&chatSettings.advancedSettings.utilityButtonWidth, CustomizationKeys.utilityButtonWidth.getCGFloat(from: settings))
131
- setNotNil(&chatSettings.advancedSettings.utilityButtonBottomMargin, CustomizationKeys.utilityButtonBottomMargin.getCGFloat(from: settings))
132
- setNotNil(&chatSettings.advancedSettings.initialHeight, CustomizationKeys.initialHeight.getCGFloat(from: settings))
133
- /// Fonts
134
- if let mainFontSize = chatSettings.advancedSettings.mainFont?.pointSize {
135
- setNotNil(&chatSettings.advancedSettings.mainFont, CustomizationKeys.mainFont.getFont(from: settings, with: mainFontSize))
136
- }
137
- if let charCountFontSize = chatSettings.advancedSettings.charCountFont?.pointSize {
138
- setNotNil(&chatSettings.advancedSettings.charCountFont, CustomizationKeys.chatCountFont.getFont(from: settings, with: charCountFontSize))
139
- }
140
- func setNotNil<T>(_ forVariable: inout T, _ value:T?) {
141
- if let value = value { forVariable = value }
142
- }
89
+ func setNotNil<T>(_ forVariable: inout T, _ value:T?) {
90
+ if let value = value { forVariable = value }
143
91
  }
144
92
 
145
93
  @objc(setLanguage:onSuccess:onError:)
@@ -20,7 +20,6 @@ RCT_EXTERN_METHOD(showChat:)
20
20
  RCT_EXTERN_METHOD(getMessageCounter:(RCTResponseSenderBlock)resultCallback)
21
21
  RCT_EXTERN_METHOD(setWidgetTheme:)
22
22
  RCT_EXTERN_METHOD(setChatCustomization:)
23
- RCT_EXTERN_METHOD(setupChatSettings:)
24
23
  RCT_EXTERN_METHOD(setLanguage:(NSString *)data onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
25
24
  RCT_EXTERN_METHOD(setChatJwt:)
26
25
  RCT_EXTERN_METHOD(setChatJwtProvider)
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": "13.8.0",
4
+ "version": "13.8.1",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "./src/index.js",
7
7
  "scripts": {
package/src/index.d.ts CHANGED
@@ -49,6 +49,9 @@ declare namespace MobileMessagingReactNative {
49
49
  storageBucket?: string;
50
50
  projectId: string;
51
51
  };
52
+ notificationChannelId?: string;
53
+ notificationChannelName?: string;
54
+ notificationSound?: string;
52
55
  } | undefined;
53
56
  privacySettings?: {
54
57
  applicationCodePersistingDisabled?: boolean | undefined;
@@ -218,12 +221,12 @@ declare namespace MobileMessagingReactNative {
218
221
  }
219
222
 
220
223
  export interface ToolbarCustomization {
221
- titleTextAppearance: string;
222
- titleTextColor: string;
223
- titleText: string;
224
- titleCentered: boolean;
225
- backgroundColor: string;
226
- navigationIcon: string;
224
+ titleTextAppearance: string;
225
+ titleTextColor: string;
226
+ titleText: string;
227
+ titleCentered: boolean;
228
+ backgroundColor: string;
229
+ navigationIcon: string;
227
230
  navigationIconTint: string;
228
231
  subtitleTextAppearance: string; // android only
229
232
  subtitleTextColor: string; // android only
@@ -236,8 +239,8 @@ declare namespace MobileMessagingReactNative {
236
239
  chatStatusBarIconsColorMode: string;
237
240
  chatToolbar: ToolbarCustomization;
238
241
  attachmentPreviewToolbar: ToolbarCustomization;
239
- attachmentPreviewToolbarSaveMenuItemIcon: string;
240
- attachmentPreviewToolbarMenuItemsIconTint: string;
242
+ attachmentPreviewToolbarSaveMenuItemIcon: string;
243
+ attachmentPreviewToolbarMenuItemsIconTint: string;
241
244
  networkErrorText: string;
242
245
  networkErrorTextColor: string;
243
246
  networkErrorTextAppearance: string;
@@ -587,40 +590,12 @@ declare namespace MobileMessagingReactNative {
587
590
  */
588
591
  setChatCustomization(customization: ChatCustomization): void;
589
592
 
590
- /**
591
- * Set custom style of In-app chat
592
- * @deprecated use setChatCustomization above
593
- * @param configuration various colors in hex format, texts, margins etc.
594
- * example:
595
- * {
596
- * toolbarTitle: "Chat",
597
- * toolbarTitleColor: "#FFFFFF",
598
- * toolbarTintColor: "#FFFFFF",
599
- * ...
600
- * }
601
- */
602
- setupChatSettings(configuration: ChatCustomizationConfiguration): void;
603
-
604
593
  /**
605
594
  * Set widget theme for In-app chat messages
606
595
  * @param widgetTheme the name of the existing widget theme to be applied to customize the chat messages.
607
596
  */
608
597
  setWidgetTheme(widgetTheme: string): void;
609
598
 
610
- /**
611
- * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
612
- * Set contextual data of the Livechat Widget.
613
- * If the function is called when the chat is loaded, data will be sent immediately, otherwise they will be sent to the chat once it is loaded.
614
- * Every function invocation will overwrite the previous contextual data.
615
- *
616
- * @name sendContextualData
617
- * @param data contextual data in the form of JSON string
618
- * @param allMultiThreadStrategy multi-thread strategy flag, true -> ALL, false -> ACTIVE
619
- * @param {Function} onSuccess success callback
620
- * @param {Function} onError error callback
621
- */
622
- sendContextualData(data: string, allMultiThreadStrategy: boolean, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
623
-
624
599
  /**
625
600
  * Set contextual data of the Livechat Widget.
626
601
  * If the function is called when the chat is loaded, data will be sent immediately, otherwise they will be sent to the chat once it is loaded.
package/src/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import {
1
+ import {
2
2
  EmitterSubscription,
3
3
  NativeEventEmitter,
4
4
  NativeModules,
5
- Platform,
5
+ Platform,
6
6
  } from 'react-native';
7
7
 
8
8
 
@@ -147,8 +147,11 @@ class MobileMessaging {
147
147
  * android: {
148
148
  * notificationIcon: <String>,
149
149
  * multipleNotifications: <Boolean>,
150
- * notificationAccentColor: <String>
151
- * firebaseOptions: <Object>
150
+ * notificationAccentColor: <String>,
151
+ * firebaseOptions: <Object>,
152
+ * notificationChannelId: <String>,
153
+ * notificationChannelName: <String>,
154
+ * notificationSound: <String>
152
155
  * }
153
156
  * privacySettings: {
154
157
  * applicationCodePersistingDisabled: <Boolean>,
@@ -578,22 +581,6 @@ class MobileMessaging {
578
581
  RNMMChat.setChatCustomization(customization)
579
582
  };
580
583
 
581
- /**
582
- * Set custom style of In-app chat
583
- * @deprecated use setChatCustomization instead
584
- * @param configuration various colors in hex format, texts, margins etc.
585
- * example:
586
- * {
587
- * toolbarTitle: "Chat",
588
- * toolbarTitleColor: "#FFFFFF",
589
- * toolbarTintColor: "#FFFFFF",
590
- * ...
591
- * }
592
- */
593
- setupChatSettings(configuration) {
594
- RNMMChat.setupChatSettings(configuration)
595
- };
596
-
597
584
  /**
598
585
  * Set widget theme for In-app chat messages
599
586
  * @param widgetTheme the name of the existing widget theme to be applied to customize the chat messages.
@@ -615,26 +602,6 @@ class MobileMessaging {
615
602
  RNMMChat.setLanguage(localeString, onSuccess, onError);
616
603
  };
617
604
 
618
- /**
619
- * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
620
- * Set contextual data of the Livechat Widget.
621
- * If the function is called when the chat is loaded, data will be sent immediately, otherwise they will be sent to the chat once it is loaded.
622
- * Every function invocation will overwrite the previous contextual data.
623
- *
624
- * @name sendContextualData
625
- * @param data - contextual data in the form of JSON string
626
- * @param allMultiThreadStrategy - multi-thread strategy flag, true -> ALL, false -> ACTIVE
627
- * @param {Function} onSuccess success callback
628
- * @param {Function} onError error callback
629
- */
630
- sendContextualData(data, allMultiThreadStrategy = false, onSuccess = function() {}, onError = function() {}) {
631
- if (allMultiThreadStrategy) {
632
- sendContextualData(data, 'ALL', onSuccess, onError)
633
- } else {
634
- sendContextualData(data, 'ACTIVE', onSuccess, onError)
635
- }
636
- };
637
-
638
605
  /**
639
606
  * Set contextual data of the Livechat Widget.
640
607
  * If the function is called when the chat is loaded, data will be sent immediately, otherwise they will be sent to the chat once it is loaded.
@@ -705,7 +672,7 @@ class MobileMessaging {
705
672
  * });
706
673
  * ```
707
674
  *
708
- * > ⚠️ This callback may be invoked multiple times during the widget's lifecycle
675
+ * > ⚠️ This callback may be invoked multiple times during the widget's lifecycle
709
676
  * (e.g., due to screen orientation changes or network reconnection).
710
677
  * It is important to return a **fresh and valid JWT** each time.
711
678
  *
@@ -827,7 +794,7 @@ export const mobileMessaging = new MobileMessaging();
827
794
  class WebRTCUI {
828
795
  /**
829
796
  * Manually enable WebRTCUI calls, provided a valid configuration Id exists in the webRTCUI configuration. This function is used to control when to start
830
- * calls, for example if you want to enabled it only after a successful user authentication. Note: Device settings, such as "Do not disturb" modes, will
797
+ * calls, for example if you want to enabled it only after a successful user authentication. Note: Device settings, such as "Do not disturb" modes, will
831
798
  * ignore this method until the operating system allows calls.
832
799
  * @name enableCalls
833
800
  * @param identity String value to use as identity in the registration for WebRTC calls. If empty string is set, push registration Id will be used
@@ -840,7 +807,7 @@ class WebRTCUI {
840
807
 
841
808
  /**
842
809
  * Manually enable WebRTCUI calls, provided a valid configuration Id exists in the webRTCUI configuration. This function is used to control when to start
843
- * calls, for example if you want to enabled it only after a successful user authentication. Note: Device settings, such as "Do not disturb" modes, will
810
+ * calls, for example if you want to enabled it only after a successful user authentication. Note: Device settings, such as "Do not disturb" modes, will
844
811
  * ignore this method until the operating system allows calls.
845
812
  * @name enableChatCalls
846
813
  * @param {Function} onSuccess success callback