OneSignal / OneSignal-DotNet-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your .NET app with OneSignal. https://onesignal.com
MIT License
16 stars 5 forks source link

[question]: How to implement OSRemoteNotificationReceivedHandler #34

Closed nadirbongiovanni closed 1 year ago

nadirbongiovanni commented 1 year ago

How can we help?

It seems that it is not possible to make the OSRemoteNotificationReceivedHandler working following the guide on https://documentation.onesignal.com/docs/service-extensions. It seems impossible to add any piece of code to override a push notification before it is shown in the notification center. How do I implement this in a .NET MAUI project?

Code of Conduct

brismithers commented 1 year ago

Hi @nadirbongiovanni . At this time the notification service extension (NSE) does not have a platform-independent way to implement.

On iOS, .NET 6/7 does not yet have tooling support to create an iOS NSE, but we do have an example in our sample project. Specifically, take a look at this project to see how you can set up the NSE for your app.

On Android, you must implement a native NSE via these instructions.

Note there is the OneSignal.Default.NotificationWillShowevent, however that is only called when the app is in the foreground. If you do require overriding a push notification on Android while the app is in the background/closed, would you be willing to share your use case?

Thanks and hope this helps.