infobip-mobile-messaging-react-native-plugin 9.2.2 → 9.3.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.
@@ -11,6 +11,7 @@ def overrideGmsVersion = getRootProjectProperty('overrideGmsVersion', '')
11
11
  def overrideFirebaseVersion = getRootProjectProperty('overrideFirebaseVersion', '')
12
12
  def overrideKotlinVersion = getRootProjectProperty('overrideKotlinVersion', '')
13
13
  def withCryptorMigration = getRootProjectProperty('withCryptorMigration', false)
14
+ def withGeofencingModule = getRootProjectProperty('withGeofencingModule', false)
14
15
  def withWebRTCUI = getRootProjectProperty('withWebRTCUI', false)
15
16
 
16
17
  apply plugin: 'com.android.library'
@@ -86,7 +87,7 @@ repositories {
86
87
  }
87
88
 
88
89
  dependencies {
89
- def mmVersion = '11.1.3'
90
+ def mmVersion = "11.2.0"
90
91
  //react and mm dependencies clash
91
92
  if (!overrideKotlinVersion.empty) {
92
93
  constraints {
@@ -99,10 +100,10 @@ dependencies {
99
100
  implementation 'com.google.android.material:material:1.8.0'
100
101
  implementation 'androidx.exifinterface:exifinterface:1.3.6'
101
102
  implementation 'androidx.databinding:viewbinding:8.0.2'
103
+ implementation 'com.google.android.gms:play-services-base:18.2.0'
102
104
 
103
105
  implementation "com.infobip:infobip-mobile-messaging-android-resources:$mmVersion@aar"
104
106
  implementation "com.infobip:infobip-mobile-messaging-android-chat-sdk:$mmVersion@aar"
105
- implementation "com.infobip:infobip-mobile-messaging-android-geo-sdk:$mmVersion@aar"
106
107
  implementation ("com.infobip:infobip-mobile-messaging-android-sdk:$mmVersion@aar") {
107
108
  transitive = true;
108
109
 
@@ -128,4 +129,10 @@ dependencies {
128
129
  if (withCryptorMigration.toBoolean()) {
129
130
  implementation "com.infobip:infobip-mobile-messaging-android-cryptor-migration:$mmVersion@aar"
130
131
  }
132
+
133
+ if (withGeofencingModule.toBoolean()) {
134
+ implementation ("com.infobip:infobip-mobile-messaging-android-geo-sdk:$mmVersion@aar"){
135
+ transitive = true
136
+ }
137
+ }
131
138
  }
@@ -47,8 +47,6 @@ import org.infobip.mobile.messaging.User;
47
47
  import org.infobip.mobile.messaging.chat.InAppChat;
48
48
  import org.infobip.mobile.messaging.chat.core.InAppChatEvent;
49
49
  import org.infobip.mobile.messaging.dal.bundle.MessageBundleMapper;
50
- import org.infobip.mobile.messaging.geo.GeoEvent;
51
- import org.infobip.mobile.messaging.geo.MobileGeo;
52
50
  import org.infobip.mobile.messaging.interactive.InteractiveEvent;
53
51
  import org.infobip.mobile.messaging.interactive.MobileInteractive;
54
52
  import org.infobip.mobile.messaging.interactive.NotificationAction;
@@ -72,6 +70,7 @@ import org.json.JSONArray;
72
70
  import org.json.JSONException;
73
71
  import org.json.JSONObject;
74
72
 
73
+ import java.lang.reflect.Method;
75
74
  import java.util.ArrayList;
76
75
  import java.util.Arrays;
77
76
  import java.util.HashMap;
@@ -163,6 +162,10 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
163
162
  private static final String EVENT_INAPPCHAT_LIVECHAT_REGISTRATION_ID_UPDATED = "inAppChat.livechatRegistrationIdUpdated";
164
163
  //endregion
165
164
 
165
+ //Geo dependency is opt-out by default. Extracted from GeoEvent.GEOFENCE_AREA_ENTERED module 'infobip-mobile-messaging-android-geo-sdk'
166
+ private static final String GEO_EVENT_GEOFENCE_AREA_ENTERED_KEY = "org.infobip.mobile.messaging.geo.GEOFENCE_AREA_ENTERED";
167
+
168
+
166
169
  //region MessageStorageBroadcastReceiver
167
170
  private static final Map<String, String> messageStorageEventMap = new HashMap<String, String>() {{
168
171
  put(MessageStoreAdapter.EVENT_MESSAGESTORAGE_START, MessageStoreAdapter.EVENT_MESSAGESTORAGE_START);
@@ -282,7 +285,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
282
285
  put(Event.USER_UPDATED.getKey(), EVENT_USER_UPDATED);
283
286
  put(Event.PERSONALIZED.getKey(), EVENT_PERSONALIZED);
284
287
  put(Event.DEPERSONALIZED.getKey(), EVENT_DEPERSONALIZED);
285
- put(GeoEvent.GEOFENCE_AREA_ENTERED.getKey(), EVENT_GEOFENCE_ENTERED);
288
+ put(GEO_EVENT_GEOFENCE_AREA_ENTERED_KEY, EVENT_GEOFENCE_ENTERED);
286
289
  put(InAppChatEvent.CHAT_VIEW_CHANGED.getKey(), EVENT_INAPPCHAT_VIEW_STATE_CHANGED);
287
290
  put(InAppChatEvent.CHAT_CONFIGURATION_SYNCED.getKey(), EVENT_INAPPCHAT_CONFIGURATION_SYNCED);
288
291
  put(InAppChatEvent.LIVECHAT_REGISTRATION_ID_UPDATED.getKey(), EVENT_INAPPCHAT_LIVECHAT_REGISTRATION_ID_UPDATED);
@@ -298,7 +301,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
298
301
  return;
299
302
  }
300
303
 
301
- if (GeoEvent.GEOFENCE_AREA_ENTERED.getKey().equals(intent.getAction())) {
304
+ if (GEO_EVENT_GEOFENCE_AREA_ENTERED_KEY.equals(intent.getAction())) {
302
305
  for (JSONObject geo : MessageJson.geosFromBundle(intent.getExtras())) {
303
306
  ReactNativeEvent.send(event, reactContext, geo);
304
307
  }
@@ -447,7 +450,16 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
447
450
  @Override
448
451
  public void onSuccess() {
449
452
  if (configuration.geofencingEnabled) {
450
- MobileGeo.getInstance(context).activateGeofencing();
453
+ try {
454
+ Class<?> cls = Class.forName("org.infobip.mobile.messaging.geo.MobileGeo");
455
+ Method newInstance_method = cls.getDeclaredMethod("getInstance", Context.class);
456
+ Method activateGeofencing_method = cls.getDeclaredMethod("activateGeofencing");
457
+ Object geoInstance = newInstance_method.invoke(cls, context);
458
+ activateGeofencing_method.invoke(geoInstance);
459
+ } catch (Exception e) {
460
+ Log.d(Utils.TAG, "Geofencing is not enabled.");
461
+ e.printStackTrace();
462
+ }
451
463
  }
452
464
 
453
465
  NotificationCategory categories[] = notificationCategoriesFromConfiguration(configuration.notificationCategories);
@@ -6,9 +6,9 @@ import android.util.Log;
6
6
 
7
7
  import org.infobip.reactlibrary.mobilemessaging.Utils;
8
8
 
9
+ import java.lang.reflect.Method;
10
+
9
11
  import org.infobip.mobile.messaging.Message;
10
- import org.infobip.mobile.messaging.geo.Area;
11
- import org.infobip.mobile.messaging.geo.Geo;
12
12
  import org.json.JSONArray;
13
13
  import org.json.JSONException;
14
14
  import org.json.JSONObject;
@@ -144,31 +144,16 @@ public class MessageJson {
144
144
  */
145
145
  @NonNull
146
146
  public static List<JSONObject> geosFromBundle(Bundle bundle) {
147
- Geo geo = Geo.createFrom(bundle);
148
- JSONObject message = bundleToJSON(bundle);
149
- if (geo == null || geo.getAreasList() == null || geo.getAreasList().isEmpty() || message == null) {
150
- return new ArrayList<JSONObject>();
151
- }
152
-
153
- List<JSONObject> geos = new ArrayList<JSONObject>();
154
- for (final Area area : geo.getAreasList()) {
155
- try {
156
- geos.add(new JSONObject()
157
- .put("area", new JSONObject()
158
- .put("id", area.getId())
159
- .put("center", new JSONObject()
160
- .put("lat", area.getLatitude())
161
- .put("lon", area.getLongitude()))
162
- .put("radius", area.getRadius())
163
- .put("title", area.getTitle()))
164
- );
165
- } catch (JSONException e) {
166
- Log.w(Utils.TAG, "Cannot convert geo to JSON: " + e.getMessage());
167
- Log.d(Utils.TAG, Log.getStackTraceString(e));
168
- }
147
+ try {
148
+ Class<?> cls = Class.forName("org.infobip.mobile.messaging.geo.mapper.GeoBundleMapper");
149
+ Method geosFromBundle_method = cls.getDeclaredMethod("geosFromBundle", Bundle.class);
150
+ List<JSONObject> geos = (List<JSONObject>) geosFromBundle_method.invoke(cls, bundle);
151
+ return geos;
152
+ } catch (Exception e) {
153
+ Log.w(Utils.TAG, "Cannot convert geo to JSON: " + e.getMessage());
154
+ Log.d(Utils.TAG, Log.getStackTraceString(e));
169
155
  }
170
-
171
- return geos;
156
+ return new ArrayList<JSONObject>();
172
157
  }
173
158
 
174
159
  @NonNull
@@ -188,4 +173,4 @@ public class MessageJson {
188
173
  }
189
174
  return messages;
190
175
  }
191
- }
176
+ }
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": "9.2.2",
4
+ "version": "9.3.0",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "./src/index.js",
7
7
  "scripts": {