Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background state. [Issue faced flutter 3.24.1]
Unable to listen addClickListener. previous flutter version worked
print('------- init'); #/this line print when app open print('------- listen'); #//but this line not print
Future<void> oneSignalInitial() async {
await notificationPermissions();
String oneSignalAppId = '9e2fd62d-65e4-................';
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.Debug.setAlertLevel(OSLogLevel.none);
OneSignal.consentRequired(false);
OneSignal.Notifications.addPermissionObserver((state) {
print("Has permission $state");
});
OneSignal.initialize(oneSignalAppId);
OneSignal.LiveActivities.setupDefault();
OneSignal.Notifications.addForegroundWillDisplayListener((event) {
event.preventDefault();
event.notification.display();
_handleForegroundNotification(event.notification);
});
OneSignal.User.pushSubscription.addObserver((state) async {
if (OneSignal.User.pushSubscription.id!=null){
AppPref.setValue('fcmToken', OneSignal.User.pushSubscription.id!);
}
});
print('------- init');
OneSignal.Notifications.addClickListener((notification) async {
print('------- listen');
var additionalData = notification.notification.additionalData;
if (additionalData != null) {
var type = additionalData["type"];
if (type == "calling") {
_handleCallNotificationClick(additionalData);
}
}
});
}
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
got the same problem here, any workarounds?
I'm also faced this issue, any solution please?
Also facing the same issue
Also facing the same issue
Hi @istiaksaif
What version of the OneSignal Flutter SDK are you using?
Which platform(s) are affected?
- iOS
- Android
Additionally, the app is in a backgrounded and not killed state?
Where are you calling oneSignalInitial() from?
Also facing the same issue