RocketChat / RocketChat/Rocket.Chat.ReactNative

bug: [Android] Push notification tap ignored when WebSocket is reconnecting on app foreground

Open
#7,013 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 bug type: bug
Dominant language
TypeScript
Stars
2.4k
Forks
1.5k
Avg merge
1d 18h
Merged PRs (30d)
90

Description

Describe the Bug

On Android, when a user taps a push notification while the app is backgrounded and the WebSocket has disconnected, the app opens but does not navigate to the relevant room. The notification tap is silently ignored.

The notification data is correctly stored in SharedPreferences by the native Android layer (PushNotificationModule), but the only JS code that reads it — checkPendingNotification() in app/sagas/state.js — is gated behind meteor.connected. Since the WebSocket is still reconnecting at the moment the app foregrounds, the early return at if (!isReady) { return; } is hit and checkPendingNotification() is never called.

There is no fallback — checkPendingNotification() is called in exactly one place in the entire codebase. The notification data remains in SharedPreferences until the next time the user backgrounds and re-foregrounds the app with an active WebSocket connection. If a second notification tap occurs in the meantime, the first notification is permanently overwritten and lost.

This is Android-only. iOS uses Expo's addNotificationResponseReceivedListener which has no WebSocket dependency.

Steps to Reproduce
  1. Log in to the app on a physical Android device
  2. Background the app and wait 3–5 minutes for the WebSocket to disconnect (or enable battery optimization / restrict background activity for the app in device settings)
  3. From another account, send a message to trigger a push notification
  4. Tap the push notification from the notification shade
  5. The app opens but remains on the last visited screen — no navigation to the room
Expected Behavior

Tapping a push notification should always navigate the user to the relevant room, regardless of the current WebSocket connection state at the moment of foregrounding.

Actual Behavior

The app opens but does not navigate to the room. The notification tap is silently dropped because checkPendingNotification() in app/sagas/state.js is never reached due to the isAuthAndConnected() guard returning false while the WebSocket is reconnecting.

Rocket.Chat Server Version

NA

Rocket.Chat App Version

NA

Device Name

NA

OS Version

NA

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app/sagas/state.js by tracing the isAuthAndConnected() guard and the sole call to checkPendingNotification(). Read how the native Android PushNotificationModule stores pending data in SharedPreferences. Done means an Android notification tap still navigates to the relevant room while the WebSocket is reconnecting, without losing a subsequent pending notification.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, react-native, typescript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.