How can we help?
OneSignal.Notifications.addClickListener callback never fires on Android when app is in background or killed state (regression since 5.4.0)
OneSignal.Notifications.addClickListener callback never fires when a notification is tapped while app is in background or killed state on Android. The app opens correctly but does not navigate — the click event is silently dropped. The same setup works correctly on onesignal_flutter: 5.3.4 with no other code changes.
Setup
We initialize OneSignal in main() before runApp() and register the click listener as early as possible — immediately after WidgetsFlutterBinding.ensureInitialized():
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
OneSignal.initialize(appId);
OneSignal.Notifications.addClickListener((event) {
// never fires on 5.4.0+ when app is backgrounded or killed
print('clicked: ${event.notification.title}');
});
runApp(MyApp());
}
Steps to reproduce
Add onesignal_flutter: 5.4.0 or later
Register addClickListener as shown above
Put the app in background or kill it
Send a push notification and tap it
Expected: Listener fires with notification data and app navigates correctly
Actual: App opens to home screen, listener callback is never called
Additional finding
Even registering the listener immediately after WidgetsFlutterBinding.ensureInitialized() — before any await — does not help. This confirms the problem is not on the Flutter/Dart side. The click event is never delivered to Dart at all. INotificationClickListener.onClick() is simply never called by the Android SDK's processFromContext(), regardless of how early the Dart listener is registered.
Could you advise on the correct setup to make addClickListener reliable for background and killed state on Android with the latest SDK version?
Code of Conduct
How can we help?
OneSignal.Notifications.addClickListenercallback never fires on Android when app is in background or killed state (regression since 5.4.0)OneSignal.Notifications.addClickListener callback never fires when a notification is tapped while app is in background or killed state on Android. The app opens correctly but does not navigate — the click event is silently dropped. The same setup works correctly on
onesignal_flutter: 5.3.4with no other code changes.Setup
We initialize OneSignal in main() before runApp() and register the click listener as early as possible — immediately after WidgetsFlutterBinding.ensureInitialized():
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
OneSignal.initialize(appId);
OneSignal.Notifications.addClickListener((event) {
// never fires on 5.4.0+ when app is backgrounded or killed
print('clicked: ${event.notification.title}');
});
runApp(MyApp());
}
Steps to reproduce
Add onesignal_flutter: 5.4.0 or later
Register addClickListener as shown above
Put the app in background or kill it
Send a push notification and tap it
Expected: Listener fires with notification data and app navigates correctly
Actual: App opens to home screen, listener callback is never called
Additional finding
Even registering the listener immediately after WidgetsFlutterBinding.ensureInitialized() — before any await — does not help. This confirms the problem is not on the Flutter/Dart side. The click event is never delivered to Dart at all. INotificationClickListener.onClick() is simply never called by the Android SDK's processFromContext(), regardless of how early the Dart listener is registered.
Could you advise on the correct setup to make addClickListener reliable for background and killed state on Android with the latest SDK version?
Code of Conduct