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

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));
@@ -793,6 +793,19 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
793
793
  });
794
794
  }
795
795
 
796
+ @ReactMethod
797
+ public void cleanup(final Callback successCallback, final Callback errorCallback) {
798
+ try {
799
+ MobileMessaging mm = MobileMessaging.getInstance(reactContext.getApplicationContext());
800
+ if (mm != null) {
801
+ mm.cleanup();
802
+ }
803
+ successCallback.invoke("success");
804
+ } catch (Throwable t) {
805
+ errorCallback.invoke(Utils.callbackError(t.getMessage(), null));
806
+ }
807
+ }
808
+
796
809
  @ReactMethod
797
810
  public void depersonalizeInstallation(final String pushRegistrationId, final Callback successCallback, final Callback errorCallback) {
798
811
  if (pushRegistrationId.isEmpty()) {
@@ -876,65 +889,6 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
876
889
  }.execute();
877
890
  }
878
891
 
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
892
  /**
939
893
  * Message store adapter for JS layer
940
894
  */
@@ -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)
@@ -318,6 +318,14 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
318
318
  })
319
319
  }
320
320
 
321
+ @objc(cleanup:onError:)
322
+ func cleanup(onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
323
+ UserDefaults.standard.removeObject(forKey: RNMobileMessagingConfiguration.userDefaultsConfigKey)
324
+ MobileMessaging.cleanUpAndStop(true, completion: {
325
+ onSuccess(["success"])
326
+ })
327
+ }
328
+
321
329
  @objc(depersonalizeInstallation:onSuccess:onError:)
322
330
  func depersonalizeInstallation(pushRegistrationId: NSString, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
323
331
  MobileMessaging.depersonalizeInstallation(withPushRegistrationId: pushRegistrationId as String, completion: { (installations, error) in
@@ -30,6 +30,7 @@ RCT_EXTERN_METHOD(getInstallation:(RCTResponseSenderBlock)successCallback)
30
30
  RCT_EXTERN_METHOD(setInstallationAsPrimary:(NSString *)pushRegistrationId primary:(BOOL)primary onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
31
31
  RCT_EXTERN_METHOD(personalize:(NSDictionary *)context onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
32
32
  RCT_EXTERN_METHOD(depersonalize:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
33
+ RCT_EXTERN_METHOD(cleanup:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
33
34
  RCT_EXTERN_METHOD(depersonalizeInstallation:(NSString *)pushRegistrationId onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
34
35
 
35
36
  /*Messages and Notifications*/
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-rc",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "./src/index.js",
7
7
  "scripts": {
package/release.sh CHANGED
@@ -25,4 +25,4 @@ git commit -a -m "Release: $RELEASE_VERSION"
25
25
  git tag $RELEASE_VERSION -m "Release: $RELEASE_VERSION"
26
26
 
27
27
  # Push changes
28
- git push origin master --tags
28
+ git push origin HEAD:${BRANCH_NAME_TO_BUILD} --tags
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: [
@@ -536,6 +542,15 @@ declare namespace MobileMessagingReactNative {
536
542
  */
537
543
  depersonalize(callback: (personalizeContext: PersonalizeContext) => void, errorCallback: (error: MobileMessagingError) => void): void;
538
544
 
545
+ /**
546
+ * Erases all locally stored SDK data and stops SDK services. After cleanup
547
+ * the plugin can be re-initialized with a different application code.
548
+ *
549
+ * @param callback will be called on success
550
+ * @param errorCallback will be called on error
551
+ */
552
+ cleanup(callback: () => void, errorCallback: (error: MobileMessagingError) => void): void;
553
+
539
554
  /**
540
555
  * Performs depersonalization of the installation referenced by pushRegistrationId.
541
556
  *
@@ -604,6 +619,7 @@ declare namespace MobileMessagingReactNative {
604
619
  setWidgetTheme(widgetTheme: string): void;
605
620
 
606
621
  /**
622
+ * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
607
623
  * Set contextual data of the Livechat Widget.
608
624
  * 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
625
  * Every function invocation will overwrite the previous contextual data.
@@ -616,6 +632,19 @@ declare namespace MobileMessagingReactNative {
616
632
  */
617
633
  sendContextualData(data: string, allMultiThreadStrategy: boolean, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
618
634
 
635
+ /**
636
+ * Set contextual data of the Livechat Widget.
637
+ * 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.
638
+ * Every function invocation will overwrite the previous contextual data.
639
+ *
640
+ * @name sendContextualData
641
+ * @param data contextual data in the form of JSON string
642
+ * @param chatMultiThreadStrategy multi-thread strategy: 'ACTIVE', 'ALL', 'ALL_PLUS_NEW'
643
+ * @param {Function} onSuccess success callback
644
+ * @param {Function} onError error callback
645
+ */
646
+ sendContextualData(data: string, chatMultiThreadStrategy: ChatMultithreadStrategy, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
647
+
619
648
  /**
620
649
  * Set chat language
621
650
  * @name setLanguage
package/src/index.js CHANGED
@@ -441,6 +441,18 @@ class MobileMessaging {
441
441
  ReactNativeMobileMessaging.depersonalize(onSuccess, onError);
442
442
  };
443
443
 
444
+ /**
445
+ * Erases all locally stored SDK data and stops SDK services. After cleanup
446
+ * the plugin can be re-initialized with a different application code.
447
+ *
448
+ * @name cleanup
449
+ * @param {Function} onSuccess will be called on success
450
+ * @param {Function} onError will be called on error
451
+ */
452
+ cleanup(onSuccess = function() {}, onError = function() {}) {
453
+ ReactNativeMobileMessaging.cleanup(onSuccess, onError);
454
+ };
455
+
444
456
  /**
445
457
  * Performs depersonalization of the installation referenced by pushRegistrationId.
446
458
  *
@@ -615,6 +627,7 @@ class MobileMessaging {
615
627
  };
616
628
 
617
629
  /**
630
+ * @deprecated use sendContextualData with chatMultiThreadStrategy string param instead of allMultiThreadStrategy bool.
618
631
  * Set contextual data of the Livechat Widget.
619
632
  * 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
633
  * Every function invocation will overwrite the previous contextual data.
@@ -626,7 +639,26 @@ class MobileMessaging {
626
639
  * @param {Function} onError error callback
627
640
  */
628
641
  sendContextualData(data, allMultiThreadStrategy = false, onSuccess = function() {}, onError = function() {}) {
629
- RNMMChat.sendContextualData(data, allMultiThreadStrategy, onSuccess, onError);
642
+ if (allMultiThreadStrategy) {
643
+ sendContextualData(data, 'ALL', onSuccess, onError)
644
+ } else {
645
+ sendContextualData(data, 'ACTIVE', onSuccess, onError)
646
+ }
647
+ };
648
+
649
+ /**
650
+ * Set contextual data of the Livechat Widget.
651
+ * 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.
652
+ * Every function invocation will overwrite the previous contextual data.
653
+ *
654
+ * @name sendContextualData
655
+ * @param data - contextual data in the form of JSON string
656
+ * @param chatMultiThreadStrategy - multi-thread strategy flag: ACTIVE, ALL, ALL_PLUS_NEW
657
+ * @param {Function} onSuccess success callback
658
+ * @param {Function} onError error callback
659
+ */
660
+ sendContextualData(data, chatMultiThreadStrategy = 'ACTIVE', onSuccess = function() {}, onError = function() {}) {
661
+ RNMMChat.sendContextualData(data, chatMultiThreadStrategy, onSuccess, onError);
630
662
  };
631
663
 
632
664
  /**