From 80ab433a8bce1b7bdc16da1a26823b2cb80389cb Mon Sep 17 00:00:00 2001 From: paulolobao Date: Wed, 2 Nov 2022 12:52:58 +0100 Subject: [PATCH 1/5] created specific version for react native --- android/.vscode/settings.json | 3 +++ android/build.gradle | 3 ++- .../retail/android/react/PlotProjectsReactModuleModule.java | 4 ++-- package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 android/.vscode/settings.json diff --git a/android/.vscode/settings.json b/android/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/android/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d515fa8..a13c8c6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -130,7 +130,8 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules - api('com.plotprojects:plot-android:3.18.+') + api('com.plotprojects:plot-android:android-react-native-1.0.+') + implementation 'org.altbeacon:android-beacon-library:2.19.4' implementation 'androidx.core:core:1.1.0' implementation 'androidx.fragment:fragment:1.1.0' diff --git a/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java b/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java index 8478646..984c11c 100644 --- a/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java +++ b/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java @@ -1,6 +1,8 @@ package com.plotprojects.retail.android.react; import android.util.Log; +import android.app.Activity; + import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; @@ -38,10 +40,8 @@ public String getName() { public void initialize() { try { Plot.init(reactContext.getCurrentActivity()); - Log.i(LOG_TAG, "Activity registered"); } catch (Exception e) { Plot.init(reactContext); - Log.w(LOG_TAG, "Activity not registered, notificatins won't be sent to android 12"); } } diff --git a/package.json b/package.json index 4bb7fde..8881cc4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plotprojects-react-native-module", "title": "PlotProjectsReactModule", - "version": "1.0.13", + "version": "1.0.14", "description": "This module helps you to integrate PlotProjects plugin in react native mobile apps", "main": "index.js", "files": [ From 8d7cf6ab5fab864becee831aa16fae3a81341469 Mon Sep 17 00:00:00 2001 From: Yahya Al fayad Date: Tue, 29 Nov 2022 13:36:39 +0100 Subject: [PATCH 2/5] Updated PlotPlugin version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 9d056b3..44b5856 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -130,7 +130,7 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules - api('com.plotprojects:plot-android:3.17.+') + api('com.plotprojects:plot-android:3.19.+') implementation 'androidx.core:core:1.1.0' implementation 'androidx.fragment:fragment:1.1.0' implementation 'androidx.work:work-runtime:2.2.0' From 88dd33b77f82db37728b303e740e5ce59821d102 Mon Sep 17 00:00:00 2001 From: Yahya Al fayad Date: Wed, 30 Nov 2022 14:19:20 +0100 Subject: [PATCH 3/5] Update ReactNativeNotificationOpenReceiver.java Fix for notifications not opening on older phones --- .../ReactNativeNotificationOpenReceiver.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/plotprojects/retail/android/ReactNativeNotificationOpenReceiver.java b/android/src/main/java/com/plotprojects/retail/android/ReactNativeNotificationOpenReceiver.java index d49150b..45ce41b 100644 --- a/android/src/main/java/com/plotprojects/retail/android/ReactNativeNotificationOpenReceiver.java +++ b/android/src/main/java/com/plotprojects/retail/android/ReactNativeNotificationOpenReceiver.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.util.Log; import com.facebook.react.bridge.ReactApplicationContext; @@ -35,19 +36,33 @@ public static void unsetCallbackDefined() { @Override public void onReceive(Context context, Intent intent) { if (callbackDefined == null || !callbackDefined) { - return; + startNewActivityForOlderPhones(context); } else { try { final FilterableNotification notification = intent.getParcelableExtra("notification"); - if (notification.getData() == null) { - return; - } else { + if (notification.getData() != null) { final WritableMap data = FilterableNotificationMarshaller.toJs(notification); - reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(EVENT_NAME, data); + reactApplicationContext + .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) + .emit(EVENT_NAME, data); } + startNewActivityForOlderPhones(context); } catch (Exception e) { Log.e("ReactNotificationOpen", "Error during handling notification open", e); } } } + + public void startNewActivityForOlderPhones(Context context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + return; + } + Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if (intent != null) { + context.startActivity(intent); + } else { + Log.w("ReactNotificationOpen", "Launch intent is null!"); + } + } } From 7b2b2ca5a8bd43227d416e29d89948eb37ca8cd5 Mon Sep 17 00:00:00 2001 From: Yahya Al fayad Date: Wed, 30 Nov 2022 14:22:02 +0100 Subject: [PATCH 4/5] Update package.json Version 1.0.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8881cc4..621f94c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plotprojects-react-native-module", "title": "PlotProjectsReactModule", - "version": "1.0.14", + "version": "1.0.15", "description": "This module helps you to integrate PlotProjects plugin in react native mobile apps", "main": "index.js", "files": [ From 698f7fdb62cc80bec0b10d70408f87666b1f0799 Mon Sep 17 00:00:00 2001 From: Yahya Al fayad Date: Mon, 12 Dec 2022 14:59:11 +0100 Subject: [PATCH 5/5] Release 1.0.16 Support retrieving Device ID generated by PlotProjects. --- README.md | 12 ++++++++---- .../android/react/PlotProjectsReactModuleModule.java | 5 +++++ ios/PlotProjectsReactModule.m | 6 ++++++ ios/Podfile | 2 +- package.json | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cd76b4b..6c77de1 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,10 @@ const requestLocationPermission = async () => { initializePlot(); } else { const granted = await PermissionsAndroid.requestMultiple( - [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, - PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION]); + ["android.permission.POST_NOTIFICATIONS", + PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION, + PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, + ]); if (granted['android.permission.ACCESS_COARSE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED || granted['android.permission.ACCESS_FINE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED ) { @@ -65,6 +67,7 @@ This module supports the following methods: * `Plot.enable()` Enables PlotProjects plugin after disabling it. When you initialize the plugin using `Plot.initialize()` it is enabled by default. * `Plot.disable()` Disables PlotProjects plugin. * `Plot.isEnabled(callback);` Checks if PlotProjects plugin is enabled. Callback will receive one boolean argument represents the result of this check. +* `plot.deviceId(callback);` Retrieve a unique identifier assigned to this install by PlotProjects. * `Plot.sendAttributionEvent("read_flyer", "discounts_week_12");` Sets an attribution event with key and value. It can be useful to tie some actions users take to events. * `Plot.setStringSegmentationProperty("gender", "man");` Sets a string segmentation property. * `Plot.setBooleanSegmentationProperty("is_true", true);` Sets a boolean segmentation property. @@ -75,7 +78,7 @@ This module supports the following methods: * `Plot.registerNotificationFilter(callback);` Registers a notification filter so that you can filter notifications before they are sent to the user. An example of a call to that method is: ```javascript -Plot.registerNotificationFilter((batchId, notifications) => { + Plot.registerNotificationFilter((batchId, notifications) => { notifications[0]['message'] = 'New message'; Plot.filterNotifications(batchId, JSON.stringify(notifications)); }); @@ -87,7 +90,7 @@ You need to call `Plot.filterNotifications(batchId, JSON.stringify(notifications * `Plot.registerGeotriggerHandler(callback)` register a geotrigger handler. An example of a call to this method is: ```javascript -Plot.registerGeotriggerHandler((batchId, geotriggers) => { + Plot.registerGeotriggerHandler((batchId, geotriggers) => { Plot.handleGeotriggers(batchId, JSON.stringify(geotriggers)); }); ``` @@ -98,3 +101,4 @@ You need to call `Plot.handleGeotriggers(batchId, JSON.stringify(geotriggers));` * `Plot.registerNotificationOpenHandler(callback);` register a callback when user opens (tabs) a notification. Callback will have one parameter represents the opened notification. * `Plot.getLoadedNotifications(callback);` retrieve the nearest 200 loaded notifications. Callback will have one parameter contains an array of the loaded notifications. * `Plot.getLoadedGeotriggers(callback);` retrieve the nearest 200 loaded geotriggers. Callback will have one parameter contains an array of the loaded geotriggers. +* `Plot.deviceId(callback);` retrieve PlotProjects specific device ID. diff --git a/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java b/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java index 984c11c..7b691f0 100644 --- a/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java +++ b/android/src/main/java/com/plotprojects/retail/android/react/PlotProjectsReactModuleModule.java @@ -60,6 +60,11 @@ public void isEnabled(Callback callback) { callback.invoke(Plot.isEnabled()); } + @ReactMethod + public void deviceId(Callback callback) { + Plot.deviceId(callback::invoke); + } + @ReactMethod public void setAdvertisingId(String advertisingId, Boolean limitAdTracking) { Plot.setAdvertisingId(advertisingId, limitAdTracking); diff --git a/ios/PlotProjectsReactModule.m b/ios/PlotProjectsReactModule.m index a3e154b..ba47c61 100644 --- a/ios/PlotProjectsReactModule.m +++ b/ios/PlotProjectsReactModule.m @@ -35,6 +35,12 @@ @implementation PlotProjectsReactModule callback(@[[NSNumber numberWithBool:[Plot isEnabled]]]); } +RCT_EXPORT_METHOD(deviceId:(RCTResponseSenderBlock)callback) { + [Plot deviceId:^(NSString* deviceId) { + callback(@[deviceId]); + }]; +} + RCT_EXPORT_METHOD(sendAttributionEvent:(NSString*)actionName itemId:(NSString*)itemId) { [Plot sendAttributionEvent:actionName withItemId:itemId]; } diff --git a/ios/Podfile b/ios/Podfile index 6b65fc7..7d1b957 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment the next line to define a global platform for your project -platform :ios, '14.5' +platform :ios, '16.0' target 'PlotProjectsReactModule' do # Comment the next line if you don't want to use dynamic frameworks diff --git a/package.json b/package.json index 621f94c..efb8f6a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "plotprojects-react-native-module", "title": "PlotProjectsReactModule", - "version": "1.0.15", + "version": "1.0.16", "description": "This module helps you to integrate PlotProjects plugin in react native mobile apps", "main": "index.js", "files": [