Skip to content

Fix Android deep link push notifications causing app restart in foreground#366

Draft
imSzukala wants to merge 2 commits intomainfrom
irena/deep-links-fix
Draft

Fix Android deep link push notifications causing app restart in foreground#366
imSzukala wants to merge 2 commits intomainfrom
irena/deep-links-fix

Conversation

@imSzukala
Copy link
Contributor

@imSzukala imSzukala commented Feb 16, 2026

When the app is in the foreground and receives an Intercom push notification with a deep link, the app was unexpectedly restarting (showing splash screen) before navigating to the deep link destination.

Root cause:

  • handleRemotePushMessage() always added the launch intent to TaskStackBuilder
  • getLaunchIntentForPackage() returns an intent with FLAG_ACTIVITY_NEW_TASK
  • This caused the app to restart even when already in foreground

Solution:

  • Added isAppInForeground() helper method to detect app state
  • Only add launch intent to TaskStackBuilder when app is in background/killed
  • When app is in foreground, use empty TaskStackBuilder for direct navigation

before:

Screen_recording_20260216_160250.webm

after:

Screen_recording_20260216_160852.webm

…round

When the app is in the foreground and receives an Intercom push notification
with a deep link, the app was unexpectedly restarting (showing splash screen)
before navigating to the deep link destination.

Root cause:
- handleRemotePushMessage() always added the launch intent to TaskStackBuilder
- getLaunchIntentForPackage() returns an intent with FLAG_ACTIVITY_NEW_TASK
- This caused the app to restart even when already in foreground

Solution:
- Added isAppInForeground() helper method to detect app state
- Only add launch intent to TaskStackBuilder when app is in background/killed
- When app is in foreground, use empty TaskStackBuilder for direct navigation

Changes:
- Modified android/src/newarch/IntercomModule.java
- Modified android/src/oldarch/IntercomModule.java
- Added ActivityManager and Context imports
- Added isAppInForeground() private static method
- Updated handleRemotePushMessage() to check app state

Benefits:
- Foreground: Deep links navigate directly without app restart
- Background/Killed: Behavior unchanged, app launches then navigates
- No breaking changes, maintains backward compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments