OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

[question]: OneSignal.Default.NotificationWillShow delegate not invoked #386

Open tele-bird opened 2 months ago

tele-bird commented 2 months ago

How can we help?

Immediately after invoking OneSignal.Default.Initialize(), we wireup delegates for NotificationWillShow and NotificationOpened, however I'm only seeing NotificationOpened being invoked when I send test push notifications to my device from the portal. Shouldn't I see NoficationWillShow invoked first (and then NotificationOpened when the user taps on the notification)? This happens on both Android and iOS. Am I doing something wrong?

` public void Initialize(string appId) {

if DEBUG

            OneSignal.Default.LogLevel = LogLevel.VERBOSE;

endif

            OneSignal.Default.Initialize(appId);
            OneSignal.Default.NotificationWillShow += OneSignal_NotificationWillShow;
            OneSignal.Default.NotificationOpened += OneSignal_NotificationOpened;
    }

`

Code of Conduct

tele-bird commented 2 months ago

I have attached our debug log. At the bottom of the log, you can see that my delegate for the NotificationOpened event was invoked. So this means that the notification appears without first invoking the NotificationWillShow delegate.

debug_log.txt

tele-bird commented 2 months ago

After some experimentation, it seems that the NotificationWillShow delegate only gets invoked when the app is already running and is in the foreground at the moment that the push notification is received. Is this the intended behavior for that delegate? What I need is a delegate that gets invoked every time a notification is received. I want to use it to decide whether the notification will be shown on-screen. Does such a thing exist? Using the latest version 4.3.5 of your package.