From 6d6d2b9772cf1c3feecf7c79a34cd7d6eecf996d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Irena=20Szuka=C5=82a?= Date: Wed, 25 Feb 2026 17:38:02 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"Fix=20Android=20deep=20link=20push=20?= =?UTF-8?q?notifications=20causing=20app=20restart=20in=20foreg=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 524a2fd8ef2a2309eab84395e54238854e956157. --- android/src/newarch/IntercomModule.java | 36 +++---------------------- android/src/oldarch/IntercomModule.java | 36 +++---------------------- 2 files changed, 6 insertions(+), 66 deletions(-) diff --git a/android/src/newarch/IntercomModule.java b/android/src/newarch/IntercomModule.java index 9d1d01f0..c892bd10 100644 --- a/android/src/newarch/IntercomModule.java +++ b/android/src/newarch/IntercomModule.java @@ -1,7 +1,6 @@ package com.intercom.reactnative; import android.app.Activity; -import android.app.ActivityManager; import android.app.Application; import android.content.Intent; import android.util.Log; @@ -91,14 +90,10 @@ public static void handleRemotePushWithCustomStack(@NonNull Application applicat public static void handleRemotePushMessage(@NonNull Application application, RemoteMessage remoteMessage) { try { TaskStackBuilder customStack = TaskStackBuilder.create(application); - - if (!isAppInForeground(application)) { - Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); - if (launchIntent != null) { - customStack.addNextIntent(launchIntent); - } + Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); + if (launchIntent != null) { + customStack.addNextIntent(launchIntent); } - handleRemotePushWithCustomStack(application, remoteMessage, customStack); } catch (Exception err) { Log.e(NAME, "handleRemotePushMessage error:"); @@ -106,31 +101,6 @@ public static void handleRemotePushMessage(@NonNull Application application, Rem } } - private static boolean isAppInForeground(@NonNull Application application) { - try { - ActivityManager activityManager = (ActivityManager) application.getSystemService(android.content.Context.ACTIVITY_SERVICE); - if (activityManager == null) { - return false; - } - java.util.List appProcesses = activityManager.getRunningAppProcesses(); - if (appProcesses == null) { - return false; - } - String packageName = application.getPackageName(); - for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { - if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND - && appProcess.processName.equals(packageName)) { - return true; - } - } - return false; - } catch (Exception err) { - Log.e(NAME, "isAppInForeground error:"); - Log.e(NAME, err.toString()); - return false; - } - } - public static void sendTokenToIntercom(Application application, @NonNull String token) { if (application == null || token == null || token.isEmpty()) { Log.w(NAME, "sendTokenToIntercom: application or token is null or empty"); diff --git a/android/src/oldarch/IntercomModule.java b/android/src/oldarch/IntercomModule.java index 3e19270a..32afd733 100644 --- a/android/src/oldarch/IntercomModule.java +++ b/android/src/oldarch/IntercomModule.java @@ -1,7 +1,6 @@ package com.intercom.reactnative; import android.app.Activity; -import android.app.ActivityManager; import android.app.Application; import android.content.Intent; import android.util.Log; @@ -83,14 +82,10 @@ public static void handleRemotePushWithCustomStack(@NonNull Application applicat public static void handleRemotePushMessage(@NonNull Application application, RemoteMessage remoteMessage) { try { TaskStackBuilder customStack = TaskStackBuilder.create(application); - - if (!isAppInForeground(application)) { - Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); - if (launchIntent != null) { - customStack.addNextIntent(launchIntent); - } + Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); + if (launchIntent != null) { + customStack.addNextIntent(launchIntent); } - handleRemotePushWithCustomStack(application, remoteMessage, customStack); } catch (Exception err) { Log.e(NAME, "handleRemotePushMessage error:"); @@ -98,31 +93,6 @@ public static void handleRemotePushMessage(@NonNull Application application, Rem } } - private static boolean isAppInForeground(@NonNull Application application) { - try { - ActivityManager activityManager = (ActivityManager) application.getSystemService(android.content.Context.ACTIVITY_SERVICE); - if (activityManager == null) { - return false; - } - java.util.List appProcesses = activityManager.getRunningAppProcesses(); - if (appProcesses == null) { - return false; - } - String packageName = application.getPackageName(); - for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { - if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND - && appProcess.processName.equals(packageName)) { - return true; - } - } - return false; - } catch (Exception err) { - Log.e(NAME, "isAppInForeground error:"); - Log.e(NAME, err.toString()); - return false; - } - } - public static void sendTokenToIntercom(Application application, @NonNull String token) { intercomPushClient.sendTokenToIntercom(application, token); Log.d(NAME, "sendTokenToIntercom");