From 6ffe7b2ce2848c9af17f47f850765a1df989694c Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 11:25:44 +0400 Subject: [PATCH 1/6] Add Flags --- src/android/io/ionic/links/IonicDeeplink.java | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index 000d233..0e2469b 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -10,37 +10,29 @@ */ package io.ionic.links; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; +import android.provider.Settings; +import android.util.Log; + import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaWebView; import org.apache.cordova.PluginResult; -import org.apache.cordova.PluginResult.Status; -import org.json.JSONObject; import org.json.JSONArray; import org.json.JSONException; - -import java.util.Date; -import java.util.TimeZone; - -import android.util.Log; -import android.content.Intent; -import android.content.Context; -import android.graphics.Rect; -import android.util.DisplayMetrics; -import android.view.View; -import android.view.ViewTreeObserver.OnGlobalLayoutListener; -import android.view.inputmethod.InputMethodManager; -import android.telephony.TelephonyManager; -import android.net.Uri; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.provider.Settings; +import org.json.JSONObject; import java.util.ArrayList; -import java.util.Set; import java.util.Collection; +import java.util.Date; import java.util.Map; +import java.util.Set; +import java.util.TimeZone; public class IonicDeeplink extends CordovaPlugin { private static final String TAG = "IonicDeeplinkPlugin"; @@ -63,6 +55,10 @@ public void onNewIntent(Intent intent) { public void handleIntent(Intent intent) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + Uri referrer = cordova.getActivity().getReferrer(); if (referrer != null && referrer.getHost() != null){ if (referrer.getHost().equals("com.salesforce.chatter")) { From f1bce466fd1565032d46ea54a19fbad12b623e12 Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 13:05:21 +0400 Subject: [PATCH 2/6] finishAndRemoveTask & startActivity --- src/android/io/ionic/links/IonicDeeplink.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index 0e2469b..de8a36a 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -58,6 +58,8 @@ public void handleIntent(Intent intent) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + cordova.getActivity().finishAndRemoveTask(); + cordova.getActivity().startActivity(intent); Uri referrer = cordova.getActivity().getReferrer(); if (referrer != null && referrer.getHost() != null){ From a9e4137ae85c9a1247f97d25c96549aad0867991 Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 13:23:08 +0400 Subject: [PATCH 3/6] RM startActivity --- src/android/io/ionic/links/IonicDeeplink.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index de8a36a..70ef731 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -59,7 +59,6 @@ public void handleIntent(Intent intent) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); cordova.getActivity().finishAndRemoveTask(); - cordova.getActivity().startActivity(intent); Uri referrer = cordova.getActivity().getReferrer(); if (referrer != null && referrer.getHost() != null){ From 9f97b21bc9910c5039b2757e6219a2db3950c9c8 Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 14:59:26 +0400 Subject: [PATCH 4/6] isTaskRoot --- src/android/io/ionic/links/IonicDeeplink.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index 70ef731..d1c27c9 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -54,11 +54,9 @@ public void onNewIntent(Intent intent) { } public void handleIntent(Intent intent) { - - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - cordova.getActivity().finishAndRemoveTask(); + if (cordova.getActivity().isTaskRoot()) { + cordova.getActivity().finish(); + } Uri referrer = cordova.getActivity().getReferrer(); if (referrer != null && referrer.getHost() != null){ From ac98f1c00bf7a9755cfa83222e9324f988f0e45d Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 15:22:13 +0400 Subject: [PATCH 5/6] !cordova.getActivity().isTaskRoot() --- src/android/io/ionic/links/IonicDeeplink.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index d1c27c9..5959092 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -54,7 +54,7 @@ public void onNewIntent(Intent intent) { } public void handleIntent(Intent intent) { - if (cordova.getActivity().isTaskRoot()) { + if (!cordova.getActivity().isTaskRoot()) { cordova.getActivity().finish(); } From ac723d26f88061660c4c8b53e0ba410d3df77853 Mon Sep 17 00:00:00 2001 From: zfir Date: Mon, 14 Nov 2022 16:51:12 +0400 Subject: [PATCH 6/6] Merge Intent-Filters --- plugin.xml | 40 +++---------------- src/android/io/ionic/links/IonicDeeplink.java | 35 +++++++++------- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/plugin.xml b/plugin.xml index b59513d..7681caf 100644 --- a/plugin.xml +++ b/plugin.xml @@ -52,41 +52,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/src/android/io/ionic/links/IonicDeeplink.java b/src/android/io/ionic/links/IonicDeeplink.java index 5959092..000d233 100644 --- a/src/android/io/ionic/links/IonicDeeplink.java +++ b/src/android/io/ionic/links/IonicDeeplink.java @@ -10,29 +10,37 @@ */ package io.ionic.links; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Bundle; -import android.provider.Settings; -import android.util.Log; - import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaWebView; import org.apache.cordova.PluginResult; +import org.apache.cordova.PluginResult.Status; +import org.json.JSONObject; import org.json.JSONArray; import org.json.JSONException; -import org.json.JSONObject; + +import java.util.Date; +import java.util.TimeZone; + +import android.util.Log; +import android.content.Intent; +import android.content.Context; +import android.graphics.Rect; +import android.util.DisplayMetrics; +import android.view.View; +import android.view.ViewTreeObserver.OnGlobalLayoutListener; +import android.view.inputmethod.InputMethodManager; +import android.telephony.TelephonyManager; +import android.net.Uri; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.provider.Settings; import java.util.ArrayList; +import java.util.Set; import java.util.Collection; -import java.util.Date; import java.util.Map; -import java.util.Set; -import java.util.TimeZone; public class IonicDeeplink extends CordovaPlugin { private static final String TAG = "IonicDeeplinkPlugin"; @@ -54,9 +62,6 @@ public void onNewIntent(Intent intent) { } public void handleIntent(Intent intent) { - if (!cordova.getActivity().isTaskRoot()) { - cordova.getActivity().finish(); - } Uri referrer = cordova.getActivity().getReferrer(); if (referrer != null && referrer.getHost() != null){