From fb497cebfe8ff6bebf2748257cf0b61568afdce4 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Thu, 31 Oct 2019 07:55:36 +0100 Subject: [PATCH] app head: fix launch urls and notification target urls --- app | 2 +- src/main/java/io/lbry/browser/MainActivity.java | 11 ----------- .../browser/reactmodules/UtilityModule.java | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app b/app index f7143106..943c5654 160000 --- a/app +++ b/app @@ -1 +1 @@ -Subproject commit f714310681fa430aa84a4121ccca322bd2d6fd8e +Subproject commit 943c5654c1cf7d9246964a3bc8826cffd2ae92f4 diff --git a/src/main/java/io/lbry/browser/MainActivity.java b/src/main/java/io/lbry/browser/MainActivity.java index b3865926..f4eee2a2 100644 --- a/src/main/java/io/lbry/browser/MainActivity.java +++ b/src/main/java/io/lbry/browser/MainActivity.java @@ -534,17 +534,6 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(sourceNotificationId); } - - // check for target (notification payload) - String target = intent.getStringExtra("target"); - if (target != null && target.trim().length() > 0) { - ReactContext reactContext = mReactInstanceManager.getCurrentReactContext(); - if (reactContext != null) { - WritableMap params = Arguments.createMap(); - params.putString("url", target); - reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onNotificationTargetLaunch", params); - } - } } super.onNewIntent(intent); diff --git a/src/main/java/io/lbry/browser/reactmodules/UtilityModule.java b/src/main/java/io/lbry/browser/reactmodules/UtilityModule.java index dc5107d9..40d8c132 100644 --- a/src/main/java/io/lbry/browser/reactmodules/UtilityModule.java +++ b/src/main/java/io/lbry/browser/reactmodules/UtilityModule.java @@ -396,4 +396,21 @@ public class UtilityModule extends ReactContextBaseJavaModule { editor.commit(); } } + + @ReactMethod + public void getNotificationLaunchTarget(Promise promise) { + Activity activity = MainActivity.getActivity(); + if (activity != null) { + Intent intent = activity.getIntent(); + if (intent != null) { + String target = intent.getStringExtra("target"); + if (target != null && target.trim().length() > 0) { + promise.resolve(target); + return; + } + } + } + + promise.resolve(null); + } }