OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
[Bug]: both addForegroundWillDisplayListener and addClickListener not triggered with hms (huawei)
What happened?
Future<void> init() async {
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.Debug.setAlertLevel(OSLogLevel.none);
OneSignal.initialize(F.oneSignalKey);
await OneSignal.User.pushSubscription.optIn();
OneSignal.Notifications.addForegroundWillDisplayListener((
event,
) {
event.preventDefault();
LocalNotificationService.showNotification(
event.notification,
event.notification.additionalData?['data']['id'] ?? '',
);
});
OneSignal.Notifications.addClickListener((event) {
if (event.notification.additionalData?['action'] == 'new-order') {
NotificationHelper.navigate(
event.notification.additionalData?['data']['id'] ?? '',
);
}
});
}
It works fine in both Android and ios but it's not being triggered in hms I have following this to setup
I can receive notifications from both Onesignal BO and my backend service, but nothing happens when I click on the notification. No error log is displayed on the terminal also
Steps to reproduce?
1. Setup huawei pushkit
2. Configure huawei platform in OneSignal BO
3. trigger notification from Onesignal BO or your backend service
4. it will show a notification on your Hms phone but nothing happens after you click it
What did you expect to happen?
Same behavior just like Android and ios, both listeners will be triggered when receive or click on the notification
OneSignal Flutter SDK version
5.0.4
Which platform(s) are affected?
- [ ] iOS
- [ ] Android
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I'm getting the same issue on Harmony device. Any fix for that ?
Been having similar behavior, not only on cold start.
My app uses some native code for some other SDK. The other SDK had GeneratedPluginRegistrant.register(with: "xxx"), and it was placed AFTER GeneratedPluginRegistrant.register(with: self).
The GeneratedPluginRegistrant.register(with: self) has to be at the very end, for both Android and iOS.
example for swift:
GeneratedPluginRegistrant.register(with: xxx)
GeneratedPluginRegistrant.register(with: self) // this has to be at the very end
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Tested with latest 5.2.2 and working fine.. all handlers as expected.
Hope this helps someone.
@ihijazi
Moving the line "GeneratedPluginRegistrant.register(with: "xxx")" at the very end, fixed the problem for both Android and iOS ?
@ihijazi
Moving the line "GeneratedPluginRegistrant.register(with: "xxx")" at the very end, fixed the problem for both Android and iOS ?
It was already there for Android so can't say if the problem was there in the first place. But it did for iOS.