Open
Description
What happened?
My problem only happens when I receive a notification with the app running (in the foreground or background). When you kill the app and click on the notification, nothing happens.
The notification just disappears.
I noticed that the same problem happens with the OneSignal example project here on github.
Is this a known limitation?
In all other situations, notifications work perfectly, in the foreground, background and dead.
Steps to reproduce?
class NotificationService {
NotificationService._();
static final NotificationService instance = NotificationService._();
bool initialized = false;
bool appInBackground = false;
bool appOpenByNotification = false;
Future<void> initialize() async {
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.initialize("MY_APP_ID");
OneSignal.LiveActivities.setupDefault();
OneSignal.Notifications.clearAll();
OneSignal.Notifications.addClickListener((event) {
if (appInBackground) {
appOpenByNotification = true;
AdsService.loadAndShowNotificationAd(callback: () {
handleNotificationReceived(event);
appOpenByNotification = false;
});
} else if (initialized) {
AdsService.loadAndShowNotificationAd(callback: () {
handleNotificationReceived(event);
});
} else {
appOpenByNotification = true;
Timer.periodic(const Duration(milliseconds: 500), (timer) {
if (initialized) {
timer.cancel();
handleNotificationReceived(event);
}
});
}
});
OneSignal.Notifications.addForegroundWillDisplayListener((event) {
event.preventDefault();
event.notification.display();
});
}
}
What did you expect to happen?
I expected the closed app to start when clicking on the notification that was received when the app was running
OneSignal Flutter SDK version
5.2.8
Which platform(s) are affected?
- iOS
- Android
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels