Skip to content

Conversation

@rajveermalviya
Copy link
Member

Instead of relying on Flutter's deeplinks implementation for routing the notification URL, handle the Android Intents generated by notification taps ourselves using Pigeon to pass those events over to the Dart layer from the Java layer.

The upstream Flutter's deeplinks implementation has a bug where if the deeplink is triggered after the app was killed by the OS when it was in background, the app will get launched again but the route/link will not reach the Flutter's navigation handlers. See: flutter/flutter#178305

In the failure case we seem to be receiving the Android Intent for the notification tap from the OS via MainActivity.onNewIntent without any problems. So, to workaround that upstream bug this commit changes the implementation to handle these Android Intents ourselves.

Fixes: #1567

…Service init

NotificationOpenService.instance.start already handles all the
platforms itself, by doing nothing on all except iOS, so move it's
initialization out of the platform-specific switch here.
…cription

Initialize StreamController early, this will allow scheduling mock
notification tap events (via `addNotificationTapEvent`) even before
`notificationTapEventsStream` is called.
@rajveermalviya rajveermalviya added the maintainer review PR ready for review by Zulip maintainers label Dec 18, 2025
@rajveermalviya rajveermalviya force-pushed the pr-android-notif-intents branch from 8cb4fcb to 2e2b67b Compare December 18, 2025 15:27
Instead of relying on Flutter's deeplinks implementation for
routing the notification URL, handle the Android Intents generated
by notification taps ourselves using Pigeon to pass those events
over to the Dart layer from the Java layer.

The upstream Flutter's deeplinks implementation has a bug where if
the deeplink is triggered after the app was killed by the OS when
it was in background, the app will get launched again but the
route/link will not reach the Flutter's navigation handlers. See:
  flutter/flutter#178305

In the failure case we seem to be receiving the Android Intent for
the notification tap from the OS via `MainActivity.onNewIntent`
without any problems. So, to workaround that upstream bug this
commit changes the implementation to handle these Android Intents
ourselves.

Fixes: zulip#1567
@rajveermalviya rajveermalviya force-pushed the pr-android-notif-intents branch from 2e2b67b to 3521955 Compare December 18, 2025 18:00
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm not super familiar with this code. I think the main thing I'd like to understand is why so much in the ios/ directory is touched here, when the issue and PR description are pretty explicit that this is an Android bugfix. (There's even a name with "android" that appears in a file in ios/, which I've pointed out below; I'm confused about that.)

Comment on lines +782 to +783
late final _notificationTapEventsStreamController =
StreamController<NotificationTapEvent>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is late final intended, instead of just final?

}

/// Generated class from Pigeon that represents data sent in messages.
struct AndroidNotificationTapEvent: NotificationTapEvent {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the name AndroidNotificationTapEvent appearing in a file in ios/? That looks like a smell to me; can it be avoided?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer review PR ready for review by Zulip maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening notification sometimes doesn't navigate, on Android

2 participants