infobip-mobile-messaging-react-native-plugin 12.5.5 → 12.6.0

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.
@@ -86,7 +86,7 @@ repositories {
86
86
  }
87
87
 
88
88
  dependencies {
89
- def mmVersion = '13.2.3'
89
+ def mmVersion = '13.4.0'
90
90
  //react and mm dependencies clash
91
91
  if (!overrideKotlinVersion.empty) {
92
92
  constraints {
@@ -33,6 +33,7 @@ import org.infobip.mobile.messaging.mobileapi.Result;
33
33
  import org.infobip.mobile.messaging.util.StringUtils;
34
34
  import org.infobip.reactlibrary.mobilemessaging.datamappers.ReactNativeJson;
35
35
  import org.infobip.mobile.messaging.api.support.http.serialization.JsonSerializer;
36
+ import org.infobip.mobile.messaging.chat.core.MultithreadStrategy;
36
37
  import org.json.JSONException;
37
38
  import org.json.JSONObject;
38
39
 
@@ -120,9 +121,10 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
120
121
  }
121
122
 
122
123
  @ReactMethod
123
- public void sendContextualData(String data, Boolean allMultiThreadStrategy, Callback onSuccess, Callback onError) {
124
+ public void sendContextualData(String data, String multithreadStrategyFlag, Callback onSuccess, Callback onError) {
124
125
  try {
125
- InAppChat.getInstance(reactContext).sendContextualData(data, allMultiThreadStrategy);
126
+ MultithreadStrategy multithreadStrategy = MultithreadStrategy.valueOf(multithreadStrategyFlag);
127
+ InAppChat.getInstance(reactContext).sendContextualData(data, multithreadStrategy);
126
128
  onSuccess.invoke();
127
129
  } catch (Throwable t) {
128
130
  onError.invoke(Utils.callbackError(t.getMessage(), null));
@@ -876,65 +876,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
876
876
  }.execute();
877
877
  }
878
878
 
879
- @ReactMethod
880
- public synchronized void defaultMessageStorage_find(String messageId, final Callback callback) throws JSONException {
881
- MessageStore messageStore = MobileMessaging.getInstance(reactContext).getMessageStore();
882
- if (messageStore == null) {
883
- callback.invoke();
884
- return;
885
- }
886
-
887
- for (Message m : messageStore.findAll(reactContext)) {
888
- if (messageId.equals(m.getMessageId())) {
889
- callback.invoke(ReactNativeJson.convertJsonToMap(MessageJson.toJSON(m)));
890
- return;
891
- }
892
- }
893
- callback.invoke();
894
- }
895
-
896
- @ReactMethod
897
- public synchronized void defaultMessageStorage_findAll(final Callback callback) throws JSONException {
898
- MessageStore messageStore = MobileMessaging.getInstance(reactContext).getMessageStore();
899
- if (messageStore == null) {
900
- callback.invoke();
901
- return;
902
- }
903
- List<Message> messages = messageStore.findAll(reactContext);
904
- callback.invoke(ReactNativeJson.convertJsonToArray(MessageJson.toJSONArray(messages.toArray(new Message[messages.size()]))));
905
- }
906
-
907
- @ReactMethod
908
- public synchronized void defaultMessageStorage_delete(String messageId, final Callback callback) throws JSONException {
909
- MessageStore messageStore = MobileMessaging.getInstance(reactContext).getMessageStore();
910
- if (messageStore == null) {
911
- callback.invoke();
912
- return;
913
- }
914
-
915
- List<Message> messagesToKeep = new ArrayList<Message>();
916
- for (Message m : messageStore.findAll(reactContext)) {
917
- if (messageId.equals(m.getMessageId())) {
918
- continue;
919
- }
920
- messagesToKeep.add(m);
921
- }
922
- messageStore.deleteAll(reactContext);
923
- messageStore.save(reactContext, messagesToKeep.toArray(new Message[messagesToKeep.size()]));
924
- callback.invoke();
925
- }
926
-
927
- @ReactMethod
928
- public synchronized void defaultMessageStorage_deleteAll(final Callback callback) {
929
- MessageStore messageStore = MobileMessaging.getInstance(reactContext).getMessageStore();
930
- if (messageStore == null) {
931
- callback.invoke();
932
- return;
933
- }
934
- messageStore.deleteAll(reactContext);
935
- callback.invoke();
936
- }
937
-
938
879
  /**
939
880
  * Message store adapter for JS layer
940
881
  */
@@ -19,10 +19,10 @@ Pod::Spec.new do |s|
19
19
  s.requires_arc = true
20
20
 
21
21
  s.dependency "React-Core"
22
- s.dependency "MobileMessaging/Core", "12.14.1"
23
- s.dependency "MobileMessaging/InAppChat", "12.14.1"
24
- s.dependency "MobileMessaging/Inbox", "12.14.1"
22
+ s.dependency "MobileMessaging/Core", "12.17.0"
23
+ s.dependency "MobileMessaging/InAppChat", "12.17.0"
24
+ s.dependency "MobileMessaging/Inbox", "12.17.0"
25
25
  if defined?($WebRTCUIEnabled)
26
- s.dependency "MobileMessaging/WebRTCUI", "12.14.1"
26
+ s.dependency "MobileMessaging/WebRTCUI", "12.17.0"
27
27
  end
28
28
  end
@@ -159,20 +159,31 @@ class RNMMChat: NSObject {
159
159
  }
160
160
  }
161
161
 
162
- @objc(sendContextualData:multiThreadStrategy:onSuccess:onError:)
163
- func sendContextualData(data: NSString, multiThreadStrategy: Bool, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
164
- if let chatVC = RNMMChatView.viewController {
165
- chatVC.sendContextualData(String(data), multiThreadStrategy: multiThreadStrategy ? .ALL : .ACTIVE) { error in
166
- if let error = error {
167
- onError([error.reactNativeObject])
168
- } else {
169
- onSuccess(nil)
170
- }
171
- }
172
- } else if let inAppChat = MobileMessaging.inAppChat {
173
- inAppChat.sendContextualData(String(data), multiThreadStrategy: multiThreadStrategy ? .ALL : .ACTIVE)
174
- onSuccess(nil)
162
+ @objc(sendContextualData:chatMultiThreadStrategy:onSuccess:onError:)
163
+ func sendContextualData(data: NSString, chatMultiThreadStrategy: NSString, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
164
+ var strategy: MMChatMultiThreadStrategy
165
+ switch chatMultiThreadStrategy {
166
+ case "ACTIVE": strategy = .ACTIVE
167
+ case "ALL": strategy = .ALL
168
+ case "ALL_PLUS_NEW": strategy = .ALL_PLUS_NEW
169
+ default:
170
+ onError([NSError(type: .InvalidArguments)])
171
+ return
175
172
  }
173
+
174
+
175
+ if let chatVC = RNMMChatView.viewController {
176
+ chatVC.sendContextualData(String(data), multiThreadStrategy: strategy) { error in
177
+ if let error = error {
178
+ onError([error.reactNativeObject])
179
+ } else {
180
+ onSuccess(nil)
181
+ }
182
+ }
183
+ } else if let inAppChat = MobileMessaging.inAppChat {
184
+ inAppChat.sendContextualData(String(data), multiThreadStrategy: strategy)
185
+ onSuccess(nil)
186
+ }
176
187
  }
177
188
 
178
189
  @objc(setJwt:)
@@ -24,6 +24,7 @@ RCT_EXTERN_METHOD(setupChatSettings:)
24
24
  RCT_EXTERN_METHOD(setLanguage:(NSString *)data onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
25
25
  RCT_EXTERN_METHOD(setJwt:)
26
26
  RCT_EXTERN_METHOD(sendContextualData:(NSString *)data multiThreadStrategy:(BOOL)multiThreadStrategy onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
27
+ RCT_EXTERN_METHOD(sendContextualData:(NSString *)data chatMultiThreadStrategy:(NSString *)chatMultiThreadStrategy onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
27
28
  RCT_EXTERN_METHOD(showThreadsList)
28
29
  RCT_EXTERN_METHOD(restartConnection)
29
30
  RCT_EXTERN_METHOD(stopConnection)
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": "12.5.5",
4
+ "version": "12.6.0",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "./src/index.js",
7
7
  "scripts": {
package/src/index.d.ts CHANGED
@@ -168,13 +168,13 @@ declare namespace MobileMessagingReactNative {
168
168
  }
169
169
 
170
170
  export interface DefaultMessageStorage {
171
- find(messageId: string, callback: (message: Message) => void): void;
171
+ find(messageId: string, onSuccess: (message: Message) => void, onError: () => void): void;
172
172
 
173
- findAll(callback: (messages: Message[]) => void): void;
173
+ findAll(onSuccess: (messages: Message[]) => void, onError: () => void): void;
174
174
 
175
- delete(messageId: string, callback: () => void): void;
175
+ delete(messageId: string, onSuccess: () => void, onError: () => void): void;
176
176
 
177
- deleteAll(callback: () => void): void;
177
+ deleteAll(onSuccess: () => void, onError: () => void): void;
178
178
  }
179
179
 
180
180
  export interface CustomMessageStorage {
@@ -325,6 +325,12 @@ declare namespace MobileMessagingReactNative {
325
325
  inputTextAppearance: string;
326
326
  }
327
327
 
328
+ export enum ChatMultithreadStrategy {
329
+ active = "ACTIVE",
330
+ all = "ALL",
331
+ allPlusNew = "ALL_PLUS_NEW"
332
+ }
333
+
328
334
  interface Api {
329
335
 
330
336
  inAppChatEvents: [
@@ -604,6 +610,7 @@ declare namespace MobileMessagingReactNative {
604
610
  setWidgetTheme(widgetTheme: string): void;
605
611
 
606
612
  /**
613
+ * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
607
614
  * Set contextual data of the Livechat Widget.
608
615
  * 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.
609
616
  * Every function invocation will overwrite the previous contextual data.
@@ -616,6 +623,19 @@ declare namespace MobileMessagingReactNative {
616
623
  */
617
624
  sendContextualData(data: string, allMultiThreadStrategy: boolean, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
618
625
 
626
+ /**
627
+ * Set contextual data of the Livechat Widget.
628
+ * 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.
629
+ * Every function invocation will overwrite the previous contextual data.
630
+ *
631
+ * @name sendContextualData
632
+ * @param data contextual data in the form of JSON string
633
+ * @param chatMultiThreadStrategy multi-thread strategy: 'ACTIVE', 'ALL', 'ALL_PLUS_NEW'
634
+ * @param {Function} onSuccess success callback
635
+ * @param {Function} onError error callback
636
+ */
637
+ sendContextualData(data: string, chatMultiThreadStrategy: ChatMultithreadStrategy, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
638
+
619
639
  /**
620
640
  * Set chat language
621
641
  * @name setLanguage
package/src/index.js CHANGED
@@ -615,6 +615,7 @@ class MobileMessaging {
615
615
  };
616
616
 
617
617
  /**
618
+ * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
618
619
  * Set contextual data of the Livechat Widget.
619
620
  * 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.
620
621
  * Every function invocation will overwrite the previous contextual data.
@@ -626,7 +627,26 @@ class MobileMessaging {
626
627
  * @param {Function} onError error callback
627
628
  */
628
629
  sendContextualData(data, allMultiThreadStrategy = false, onSuccess = function() {}, onError = function() {}) {
629
- RNMMChat.sendContextualData(data, allMultiThreadStrategy, onSuccess, onError);
630
+ if (allMultiThreadStrategy) {
631
+ sendContextualData(data, 'ALL', onSuccess, onError)
632
+ } else {
633
+ sendContextualData(data, 'ACTIVE', onSuccess, onError)
634
+ }
635
+ };
636
+
637
+ /**
638
+ * Set contextual data of the Livechat Widget.
639
+ * 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.
640
+ * Every function invocation will overwrite the previous contextual data.
641
+ *
642
+ * @name sendContextualData
643
+ * @param data - contextual data in the form of JSON string
644
+ * @param chatMultiThreadStrategy - multi-thread strategy flag: ACTIVE, ALL, ALL_PLUS_NEW
645
+ * @param {Function} onSuccess success callback
646
+ * @param {Function} onError error callback
647
+ */
648
+ sendContextualData(data, chatMultiThreadStrategy = 'ACTIVE', onSuccess = function() {}, onError = function() {}) {
649
+ RNMMChat.sendContextualData(data, chatMultiThreadStrategy, onSuccess, onError);
630
650
  };
631
651
 
632
652
  /**