-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
What happened?
The following code never seems to fire - we never get the "Preventing or Allowing display of notification" message in our logs.
Environment:
Unity: 2021.3.44f1
OneSignal SDK: 5.1.10 (Android + iOS)
OneSignalSDK.OneSignal.Initialize(appId);
OneSignalSDK.OneSignal.Notifications.ForegroundWillDisplay += NotificationsOnForegroundWillDisplay;
// A log message here fires successfully
and...
private static void NotificationsOnForegroundWillDisplay(object sender, NotificationWillDisplayEventArgs e)
{
if (_focused && CoreNetworkingService.Instance != null && CoreNetworkingService.Instance.ShouldBeLoggedIn)
{
Debug.Log($"Preventing display of notification -> {e.Notification.Title}: {e.Notification.Body}");
e.PreventDefault();
}
else
{
Debug.Log($"Allowing display of notification -> {e.Notification.Title}: {e.Notification.Body}");
}
}
We need to use this to re-route notifications when the app is in the foreground. The log message is never logged, and the notification does display in the foreground on device.
Steps to reproduce?
1. See code above
2. Send push notification from backend service that targets the user on device
3. Observe the suppress never happens, nor any loggingWhat did you expect to happen?
- The event to fire as expected, and the notification to be likely suppressed.
Unity version
2021.3.44f1
OneSignal Unity SDK version
5.1.10
Platform
iOS, Android
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
No labels