infobip-mobile-messaging-react-native-plugin 5.1.0 → 6.0.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.
package/Gemfile.lock CHANGED
@@ -20,8 +20,8 @@ GEM
20
20
  addressable (~> 2.8)
21
21
  claide (>= 1.0.2, < 2.0)
22
22
  cocoapods-core (= 1.11.3)
23
- cocoapods-deintegrate (>= 1.0.3, < 2.0)
24
- cocoapods-downloader (>= 1.4.0, < 2.0)
23
+ cocoapods-deintegrate (>= 1.0.5, < 2.0)
24
+ cocoapods-downloader (>= 1.6.2, < 2.0)
25
25
  cocoapods-plugins (>= 1.0.0, < 2.0)
26
26
  cocoapods-search (>= 1.0.0, < 2.0)
27
27
  cocoapods-trunk (>= 1.4.0, < 2.0)
package/README.md CHANGED
@@ -12,7 +12,7 @@ The document describes library integration steps for your React Native project.
12
12
  ## Requirements
13
13
  - node (v16.10.0 or higher)
14
14
  - ruby (2.7.4)
15
- - React Native (v0.67.4)
15
+ - React Native (v0.68.0)
16
16
 
17
17
  For iOS project:
18
18
  - Xcode and Command Line Tools (13.2.1)
@@ -21,7 +21,7 @@ For iOS project:
21
21
 
22
22
  For Android project:
23
23
  - Android Studio (Bumblebee | 2021.1.1)
24
- - Gradle (v7.2.0)
24
+ - Gradle (v7.3.3)
25
25
  - Minimum API Level: 21 (Android 5.0 - [Lollipop](https://developer.android.com/about/versions/lollipop))
26
26
 
27
27
  ## Quick start guide
@@ -40,10 +40,10 @@ This guide is designed to get you up and running with Mobile Messaging SDK plugi
40
40
  - **iOS**
41
41
  1. Add `use_frameworks!` into `/ios/Podfile` (required for Swift frameworks such as our Mobile Messaging SDK)
42
42
  2. Run `pod install` from `/ios` folder (installs Mobile Messaging native SDK)
43
- 3. Import MobileMessaging `@import MobileMessaging;` and add `[MobileMessagingPluginApplicationDelegate install];` into `/ios/<ProjectName>/AppDelegate.m` (this is required for OS callbacks such as `didRegisterForRemoteNotifications` to be intercepted by native MobileMessaging SDK)
43
+ 3. Import following header `#import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>` and add `[MobileMessagingPluginApplicationDelegate install];` into `/ios/<ProjectName>/AppDelegate.m` (this is required for OS callbacks such as `didRegisterForRemoteNotifications` to be intercepted by native MobileMessaging SDK)
44
44
  ```objective-c
45
45
  ...
46
- @import MobileMessaging;
46
+ #import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>
47
47
 
48
48
  @implementation AppDelegate
49
49
 
@@ -67,13 +67,21 @@ This guide is designed to get you up and running with Mobile Messaging SDK plugi
67
67
  export PATH=$PATH:$ANDROID_HOME/tools/bin
68
68
  export PATH=$PATH:$ANDROID_HOME/platform-tools
69
69
  ```
70
- 2. Add [Firebase Sender Id](https://www.infobip.com/docs/mobile-app-messaging/fcm-server-api-key-setup-guide) to the `/android/app/src/main/res/values/strings.xml`
71
- ```xml
72
- <resources>
73
- ...
74
- <string name="google_app_id">your google app id</string>
75
- </resources>
70
+ 2. Add 'com.google.gms:google-services' to `android/build.gradle` file
71
+ ```groovy
72
+ buildscript {
73
+ ...
74
+ dependencies {
75
+ ...
76
+ //GMS Gradle plugin
77
+ classpath 'com.google.gms:google-services:4.3.10'
78
+ }
79
+ }
76
80
  ```
81
+ And add `apply plugin: 'com.google.gms.google-services'` at the end of your `android/app/build.gradle` in order to apply [Google Services Gradle Plugin](https://developers.google.com/android/guides/google-services-plugin)
82
+ 3. Add a Firebase configuration file (google-services.json) as described in <a href="https://firebase.google.com/docs/android/setup#add-config-file" target="_blank">`Firebase documentation`</a>
83
+ > ### Notice:
84
+ > Check <a href="https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Applying-Firebase-configuration-in-MobileMessaging-SDK">Applying Firebase configuration in MobileMessaging SDK Guide</a> for alternatives.
77
85
 
78
86
  ## Initialization configuration
79
87
 
@@ -1,32 +1,16 @@
1
- def defaultCompileSDKVersion = 30
2
- def defaultBuildToolsVersion = '30.0.2'
1
+ def defaultCompileSDKVersion = 31
2
+ def defaultBuildToolsVersion = '31.0.0'
3
3
  def defaultMinSDKVersion = 21
4
- def defaultTargetSDKVersion = 30
4
+ def defaultTargetSDKVersion = 31
5
5
 
6
6
  def getRootProjectProperty(property, fallback) {
7
7
  rootProject.ext.has(property) ? rootProject.ext.get(property) : fallback
8
8
  }
9
9
 
10
- def overrideAndroidSupportLibsVersion = getRootProjectProperty('overrideAndroidSupportLibsVersion', '')
11
10
  def overrideGmsVersion = getRootProjectProperty('overrideGmsVersion', '')
12
11
  def overrideFirebaseVersion = getRootProjectProperty('overrideFirebaseVersion', '')
13
12
  def overrideKotlinVersion = getRootProjectProperty('overrideKotlinVersion', '')
14
-
15
- if (overrideAndroidSupportLibsVersion.empty || overrideAndroidSupportLibsVersion > "26") {
16
- repositories {
17
- mavenCentral {
18
- // We don't want to fetch react-native from Maven Central as there are
19
- // older versions over there.
20
- content {
21
- excludeGroup "com.facebook.react"
22
- }
23
- }
24
- maven {
25
- url 'https://maven.google.com/'
26
- name 'Google'
27
- }
28
- }
29
- }
13
+ def withCryptorMigration = getRootProjectProperty('withCryptorMigration', false)
30
14
 
31
15
  apply plugin: 'com.android.library'
32
16
  apply plugin: 'maven-publish'
@@ -39,6 +23,7 @@ buildscript {
39
23
  if (project == rootProject) {
40
24
  repositories {
41
25
  google()
26
+ mavenLocal()
42
27
  mavenCentral {
43
28
  // We don't want to fetch react-native from Maven Central as there are
44
29
  // older versions over there.
@@ -89,15 +74,17 @@ repositories {
89
74
  }
90
75
  }
91
76
  google()
77
+ mavenLocal()
92
78
  }
93
79
 
94
80
  dependencies {
95
- def mmVersion = '5.3.6'
81
+ def mmVersion = '6.2.1'
96
82
 
97
83
  implementation 'com.facebook.react:react-native:+'
98
84
  implementation "androidx.annotation:annotation:1.1.0"
99
- implementation 'com.google.android.material:material:1.0.0'
100
- implementation 'androidx.exifinterface:exifinterface:1.1.0'
85
+
86
+ implementation 'com.google.android.material:material:1.4.0'
87
+ implementation 'androidx.exifinterface:exifinterface:1.3.3'
101
88
 
102
89
  implementation "com.infobip:infobip-mobile-messaging-android-resources:$mmVersion@aar"
103
90
  implementation "com.infobip:infobip-mobile-messaging-android-chat-sdk:$mmVersion@aar"
@@ -109,10 +96,6 @@ dependencies {
109
96
  exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
110
97
  }
111
98
 
112
- if (!overrideAndroidSupportLibsVersion.empty) {
113
- exclude group: 'com.android.support', module: 'support-v4'
114
- exclude group: 'com.android.support', module: 'appcompat-v7'
115
- }
116
99
  if (!overrideGmsVersion.empty) {
117
100
  exclude group: 'com.google.android.gms', module: 'play-services-location'
118
101
  }
@@ -120,14 +103,14 @@ dependencies {
120
103
  exclude group: 'com.google.firebase', module: 'firebase-messaging'
121
104
  }
122
105
  }
123
- if (!overrideAndroidSupportLibsVersion.empty) {
124
- implementation "com.android.support:support-v4:$overrideAndroidSupportLibsVersion"
125
- implementation "com.android.support:appcompat-v7:$overrideAndroidSupportLibsVersion"
126
- }
127
106
  if (!overrideGmsVersion.empty) {
128
107
  implementation "com.google.android.gms:play-services-location:$overrideGmsVersion"
129
108
  }
130
109
  if (!overrideFirebaseVersion.empty) {
131
110
  implementation "com.google.firebase:firebase-messaging:$overrideFirebaseVersion"
132
111
  }
133
- }
112
+
113
+ if (withCryptorMigration.toBoolean()) {
114
+ implementation "com.infobip:infobip-mobile-messaging-android-cryptor-migration:$mmVersion@aar"
115
+ }
116
+ }
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
@@ -39,8 +39,6 @@
39
39
  android:exported="false"
40
40
  android:permission="android.permission.BIND_JOB_SERVICE" />
41
41
 
42
- <receiver android:name="org.infobip.mobile.messaging.notification.NotificationTapReceiver" />
43
-
44
42
  <receiver
45
43
  android:name="org.infobip.mobile.messaging.MobileMessagingConnectivityReceiver"
46
44
  android:enabled="false"
@@ -50,8 +48,11 @@
50
48
  <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
51
49
  </intent-filter>
52
50
  </receiver>
53
- <receiver android:name="org.infobip.mobile.messaging.interactive.notification.NotificationActionTapReceiver" />
54
- <receiver android:name="org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule$MessageEventReceiver" android:exported="false">
51
+ <receiver android:name="org.infobip.mobile.messaging.interactive.notification.NotificationActionTapReceiver"
52
+ android:exported="false"/>
53
+
54
+ <receiver android:name="org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule$MessageEventReceiver"
55
+ android:exported="false">
55
56
  <intent-filter>
56
57
  <action android:name="org.infobip.mobile.messaging.MESSAGE_RECEIVED" />
57
58
  <action android:name="org.infobip.mobile.messaging.NOTIFICATION_TAPPED" />
@@ -10,12 +10,15 @@ import java.util.Map;
10
10
 
11
11
  import androidx.annotation.NonNull;
12
12
 
13
+ import com.google.firebase.FirebaseOptions;
14
+
13
15
  class Configuration {
14
16
 
15
17
  class AndroidConfiguration {
16
18
  String notificationIcon;
17
19
  boolean multipleNotifications;
18
20
  String notificationAccentColor;
21
+ FirebaseOptions firebaseOptions;
19
22
  }
20
23
 
21
24
  class PrivacySettings {
@@ -62,4 +65,4 @@ class Configuration {
62
65
 
63
66
  return config;
64
67
  }
65
- }
68
+ }
@@ -31,6 +31,8 @@ import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
31
31
  import org.infobip.mobile.messaging.mobileapi.Result;
32
32
  import org.infobip.mobile.messaging.storage.MessageStore;
33
33
  import org.infobip.mobile.messaging.storage.SQLiteMessageStore;
34
+ import org.infobip.mobile.messaging.util.Cryptor;
35
+ import org.infobip.mobile.messaging.util.DeviceInformation;
34
36
  import org.infobip.mobile.messaging.util.PreferenceHelper;
35
37
  import org.infobip.reactlibrary.mobilemessaging.datamappers.*;
36
38
  import org.infobip.mobile.messaging.dal.bundle.MessageBundleMapper;
@@ -333,6 +335,24 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
333
335
  notificationBuilder.withColor(color);
334
336
  }
335
337
  builder.withDisplayNotification(notificationBuilder.build());
338
+
339
+ if (configuration.android.firebaseOptions != null) {
340
+ builder.withFirebaseOptions(configuration.android.firebaseOptions);
341
+ }
342
+ }
343
+
344
+ // Checking do we need to migrate data saved with old cryptor,
345
+ // if withCryptorMigration project ext property is set, ECBCryptorImpl class will exist.
346
+ Cryptor cryptor = null;
347
+ try {
348
+ Class cls = Class.forName("org.infobip.mobile.messaging.cryptor.ECBCryptorImpl");
349
+ cryptor = (Cryptor) cls.getDeclaredConstructor(String.class).newInstance(DeviceInformation.getDeviceID(context));
350
+ } catch (Exception e) {
351
+ Log.d(Utils.TAG, "Will not migrate cryptor :");
352
+ e.printStackTrace();
353
+ }
354
+ if (cryptor != null) {
355
+ builder.withCryptorMigration(cryptor);
336
356
  }
337
357
 
338
358
  builder.build(new MobileMessaging.InitListener() {
@@ -1,7 +1,5 @@
1
1
  package org.infobip.reactlibrary.mobilemessaging;
2
2
 
3
- import android.widget.FrameLayout;
4
-
5
3
  import androidx.annotation.NonNull;
6
4
 
7
5
  import java.util.ArrayList;
@@ -13,7 +11,6 @@ import com.facebook.react.ReactPackage;
13
11
  import com.facebook.react.bridge.NativeModule;
14
12
  import com.facebook.react.bridge.ReactApplicationContext;
15
13
  import com.facebook.react.uimanager.ViewManager;
16
- import com.facebook.react.bridge.JavaScriptModule;
17
14
 
18
15
  public class ReactNativeMobileMessagingPackage implements ReactPackage {
19
16
 
package/index.js CHANGED
@@ -12,6 +12,8 @@ import {
12
12
  UIManager,
13
13
  EmitterSubscription,
14
14
  } from 'react-native';
15
+ import type {Rationale} from "react-native/Libraries/PermissionsAndroid/PermissionsAndroid";
16
+ import {Permission} from "react-native";
15
17
 
16
18
  const { ReactNativeMobileMessaging, RNMMChat } = NativeModules;
17
19
 
@@ -146,8 +148,14 @@ class MobileMessaging {
146
148
  * ios: {
147
149
  * notificationTypes: ['alert', 'sound', 'badge'],
148
150
  * forceCleanup: <Boolean>,
149
- * logging: <Boolean>
151
+ * logging: <Boolean>
150
152
  * },
153
+ * android: {
154
+ * notificationIcon: <String>,
155
+ * multipleNotifications: <Boolean>,
156
+ * notificationAccentColor: <String>
157
+ * firebaseOptions: <Object>
158
+ * }
151
159
  * privacySettings: {
152
160
  * applicationCodePersistingDisabled: <Boolean>,
153
161
  * userDataPersistingDisabled: <Boolean>,
@@ -242,33 +250,7 @@ class MobileMessaging {
242
250
 
243
251
  config.reactNativePluginVersion = require('./package').version;
244
252
 
245
- let geofencingEnabled = config.geofencingEnabled;
246
- if (geofencingEnabled && Platform.OS === 'android') {
247
- this.checkAndroidLocationPermission().then(granted => {
248
- if (!granted) {
249
- onError('Geofencing permission is not granted.');
250
- return;
251
- }
252
- ReactNativeMobileMessaging.init(config, onSuccess, onError);
253
- })
254
- } else {
255
- ReactNativeMobileMessaging.init(config, onSuccess, onError);
256
- }
257
- };
258
-
259
- async checkAndroidLocationPermission(): Promise<Boolean> {
260
- const locationPermissionGranted = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
261
- if (locationPermissionGranted) {
262
- return true;
263
- } else {
264
- try {
265
- const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
266
- return granted === PermissionsAndroid.RESULTS.GRANTED;
267
- } catch (err) {
268
- console.error('[RNMobileMessaging] Can\'t check android permission', err);
269
- return false;
270
- }
271
- }
253
+ ReactNativeMobileMessaging.init(config, onSuccess, onError);
272
254
  };
273
255
 
274
256
  /**
@@ -580,6 +562,64 @@ class MobileMessaging {
580
562
  resetMessageCounter() {
581
563
  RNMMChat.resetMessageCounter();
582
564
  }
565
+
566
+ /* Geofencing permissions */
567
+
568
+ /**
569
+ * This is used for requesting Location permissions for Android
570
+ * @param rationale rationale to display if it's needed. Describing why this permissions required.
571
+ * Mobile Messaging SDK requires following permissions to be able to send geo targeted notifications, even if application is killed or on background.
572
+ * ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION, ACCESS_BACKGROUND_LOCATION
573
+ * @return {Promise<boolean>}
574
+ */
575
+ async requestAndroidPermissions(rationale?: Rationale): Promise<Boolean> {
576
+ const requiredPermissions = await this.requiredAndroidLocationPermissions();
577
+ if (requiredPermissions.length === 0) {
578
+ return Promise.resolve(true);
579
+ }
580
+
581
+ return this.checkAndroidLocationPermission(requiredPermissions, rationale).then(granted => {
582
+ if (!granted) {
583
+ return Promise.resolve(false);
584
+ } else {
585
+ return this.requestAndroidPermissions(rationale);
586
+ }
587
+ });
588
+ };
589
+
590
+ async checkAndroidLocationPermission(permissions: Array<Permission>, rationale?: Rationale): Promise<Boolean> {
591
+ for (permission of permissions) {
592
+ const granted = await PermissionsAndroid.request(permission, rationale);
593
+ if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
594
+ console.log("Permissions Result != Granted ", permission, granted);
595
+ return Promise.resolve(false);
596
+ }
597
+ }
598
+ console.log("Permissions Result == Granted ");
599
+ return Promise.resolve(true);
600
+ };
601
+
602
+ async requiredAndroidLocationPermissions(): Promise<Array<Permission>> {
603
+ let permissions: Array<Permission> = [];
604
+ const fineLocationGranted = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
605
+ if (!fineLocationGranted) {
606
+ if (Platform.Version > 29) {
607
+ permissions = [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION];
608
+ } else if (Platform.Version === 29) {
609
+ permissions = [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION];
610
+ } else {
611
+ permissions = [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION];
612
+ }
613
+ } else {
614
+ const backgroundLocationGranted = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION);
615
+ if (!backgroundLocationGranted && Platform.Version > 29) {
616
+ permissions = [PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION];
617
+ }
618
+ }
619
+
620
+ return Promise.resolve(permissions);
621
+ };
622
+
583
623
  }
584
624
 
585
625
  export class ChatView extends React.Component {
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": "5.1.0",
4
+ "version": "6.0.0",
5
5
  "description": "Infobip Mobile Messaging React Native Plugin",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^17.0.2",
37
- "react-native": ">=0.67.4 <1.0.x"
37
+ "react-native": ">=0.68.0 <1.0.x"
38
38
  },
39
39
  "devDependencies": {
40
- "metro-react-native-babel-preset": "^0.66.2",
40
+ "metro-react-native-babel-preset": "^0.67.0",
41
41
  "react": "^17.0.2",
42
- "react-native": "^0.67.4"
42
+ "react-native": "^0.68.0"
43
43
  }
44
44
  }