|
1 | 1 | package com.intercom.reactnative; |
2 | 2 |
|
3 | 3 | import android.app.Activity; |
4 | | -import android.app.ActivityManager; |
5 | 4 | import android.app.Application; |
6 | 5 | import android.content.Intent; |
7 | 6 | import android.util.Log; |
@@ -83,46 +82,17 @@ public static void handleRemotePushWithCustomStack(@NonNull Application applicat |
83 | 82 | public static void handleRemotePushMessage(@NonNull Application application, RemoteMessage remoteMessage) { |
84 | 83 | try { |
85 | 84 | TaskStackBuilder customStack = TaskStackBuilder.create(application); |
86 | | - |
87 | | - if (!isAppInForeground(application)) { |
88 | | - Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); |
89 | | - if (launchIntent != null) { |
90 | | - customStack.addNextIntent(launchIntent); |
91 | | - } |
| 85 | + Intent launchIntent = application.getPackageManager().getLaunchIntentForPackage(application.getPackageName()); |
| 86 | + if (launchIntent != null) { |
| 87 | + customStack.addNextIntent(launchIntent); |
92 | 88 | } |
93 | | - |
94 | 89 | handleRemotePushWithCustomStack(application, remoteMessage, customStack); |
95 | 90 | } catch (Exception err) { |
96 | 91 | Log.e(NAME, "handleRemotePushMessage error:"); |
97 | 92 | Log.e(NAME, err.toString()); |
98 | 93 | } |
99 | 94 | } |
100 | 95 |
|
101 | | - private static boolean isAppInForeground(@NonNull Application application) { |
102 | | - try { |
103 | | - ActivityManager activityManager = (ActivityManager) application.getSystemService(android.content.Context.ACTIVITY_SERVICE); |
104 | | - if (activityManager == null) { |
105 | | - return false; |
106 | | - } |
107 | | - java.util.List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); |
108 | | - if (appProcesses == null) { |
109 | | - return false; |
110 | | - } |
111 | | - String packageName = application.getPackageName(); |
112 | | - for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { |
113 | | - if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND |
114 | | - && appProcess.processName.equals(packageName)) { |
115 | | - return true; |
116 | | - } |
117 | | - } |
118 | | - return false; |
119 | | - } catch (Exception err) { |
120 | | - Log.e(NAME, "isAppInForeground error:"); |
121 | | - Log.e(NAME, err.toString()); |
122 | | - return false; |
123 | | - } |
124 | | - } |
125 | | - |
126 | 96 | public static void sendTokenToIntercom(Application application, @NonNull String token) { |
127 | 97 | intercomPushClient.sendTokenToIntercom(application, token); |
128 | 98 | Log.d(NAME, "sendTokenToIntercom"); |
|
0 commit comments