infobip-mobile-messaging-react-native-plugin 6.2.0 → 6.2.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.
@@ -22,10 +22,12 @@ class CacheManager {
22
22
 
23
23
  static class Event {
24
24
  String type;
25
+ JSONObject jsonObject;
25
26
  Object[] objects = null;
26
27
 
27
- Event(String type, Object ... objects) {
28
+ Event(String type, JSONObject object, Object ... objects) {
28
29
  this.type = type;
30
+ this.jsonObject = object;
29
31
  this.objects = objects;
30
32
  }
31
33
 
@@ -33,6 +35,7 @@ class CacheManager {
33
35
  public String toString() {
34
36
  return type;
35
37
  }
38
+
36
39
  }
37
40
 
38
41
  static void saveEvent(Context context, String event, JSONObject object, String actionId, String actionInputText) {
@@ -41,7 +44,8 @@ class CacheManager {
41
44
  }
42
45
 
43
46
  static void saveEvent(Context context, String event, int unreadMessagesCounter) {
44
- String serialized = serializer.serialize(new Event(event, unreadMessagesCounter));
47
+ //int `unreadMessagesCounter` isn't a JSONObject, so it'll go as a second argument
48
+ String serialized = serializer.serialize(new Event(event, null, unreadMessagesCounter));
45
49
  saveStringsToSet(context, EVENTS_KEY, serialized);
46
50
  }
47
51
 
@@ -2,16 +2,13 @@ package org.infobip.reactlibrary.mobilemessaging;
2
2
 
3
3
  import android.util.Log;
4
4
 
5
- import com.facebook.react.bridge.Callback;
6
5
  import com.facebook.react.bridge.ReactContext;
7
6
  import com.facebook.react.bridge.ReadableArray;
8
7
  import com.facebook.react.bridge.ReadableMap;
9
8
  import com.facebook.react.bridge.WritableArray;
10
- import com.facebook.react.bridge.WritableMap;
11
9
  import com.facebook.react.bridge.WritableNativeArray;
12
- import com.facebook.react.bridge.WritableNativeMap;
13
10
  import com.facebook.react.modules.core.DeviceEventManagerModule;
14
- import com.google.gson.JsonIOException;
11
+
15
12
  import org.infobip.reactlibrary.mobilemessaging.datamappers.ReactNativeJson;
16
13
 
17
14
  import org.json.JSONArray;
@@ -20,8 +17,13 @@ import org.json.JSONObject;
20
17
 
21
18
 
22
19
  class ReactNativeEvent {
20
+
23
21
  static void send(String eventName, ReactContext reactContext, Object... objects) {
24
- if (objects == null) {
22
+ send(eventName, reactContext, null, objects);
23
+ }
24
+
25
+ static void send(String eventName, ReactContext reactContext, JSONObject jsonObject, Object... objects) {
26
+ if (jsonObject == null && objects == null) {
25
27
  Log.d(Utils.TAG, "objects are null, so another method should be used");
26
28
  send(eventName, reactContext);
27
29
  return;
@@ -31,6 +33,11 @@ class ReactNativeEvent {
31
33
  array.pushString(eventName);
32
34
 
33
35
  try {
36
+
37
+ if (jsonObject != null) {
38
+ array.pushMap(ReactNativeJson.convertJsonToMap(jsonObject));
39
+ }
40
+
34
41
  for (Object value : objects) {
35
42
  if (value == null) {
36
43
  continue;
@@ -70,7 +70,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
70
70
  public void initialize() {
71
71
  super.initialize();
72
72
  for (CacheManager.Event event : CacheManager.loadEvents(reactContext)) {
73
- ReactNativeEvent.send(event.type, reactContext, event.objects);
73
+ ReactNativeEvent.send(event.type, reactContext, event.jsonObject, event.objects);
74
74
  }
75
75
  pluginInitialized = true;
76
76
  registerBroadcastReceiver();
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": "6.2.0",
4
+ "version": "6.2.1",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "index.js",
7
7
  "scripts": {