Open marcin-piela-800 opened 4 months ago
Hi @marcin-piela-800 thanks for reaching out! Just to make sure I understand, only the notifications from the other push provider display? If so, that is what I would expect as our methods are meant to handle OneSignal notifications.
I'll look a bit deeper at the logic and see if there is anything we can tweak to handle notifications not coming from OneSignal.
Thanks
I implemented the following method in AppDelegate.mm
:
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
NSDictionary *userInfo = notification.request.content.userInfo;
NSString *customValue = userInfo[@"custom"]; // Added only by OneSignal
if (customValue != nil) {
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
} else {
completionHandler(UNNotificationPresentationOptionNone);
}
}
Now, I'm able to prevent notifications (other than OneSignal notifications) from being displayed when the app is in the focused state.
The problem is that it's not default behavior to show all notifications when app is focused, it's added by OneSignal so I would expect to be able to do smth with it using JS code (listener from OneSignal package)
What happened?
Version:
We're using a different package to handle push notifications from our backend. Everything works fine except we can't prevent duplicate notifications from showing when the app is in the foreground. The problem arises because the event listener for foreground notifications
is never fired for push notifications not coming from OneSignal (it is fired for OneSignal notification). However, OneSignal is firing for those notifications:
So notification is visible to the user and there is no any way for us to control it, basically we want to add some logic to skip such notifications.
Steps to reproduce?
What did you expect to happen?
OneSignal should fire
foregroundWillDisplay
to all push notifications not just OneSignal notifications, or it shouldn't show them when app is in the foregroundReact Native OneSignal SDK version
5.1.0
Which platform(s) are affected?
Relevant log output
Code of Conduct