diff --git a/OneSignalExample/Assets/OneSignal/CHANGELOG.md b/OneSignalExample/Assets/OneSignal/CHANGELOG.md index 6b51c10ac..1be7a9ced 100644 --- a/OneSignalExample/Assets/OneSignal/CHANGELOG.md +++ b/OneSignalExample/Assets/OneSignal/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Stop foreground notifications from displaying after calling prevent default on iOS + ## [5.0.1] ### Fixed - Push subscription Id and Token malloc error on iOS diff --git a/com.onesignal.unity.ios/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm b/com.onesignal.unity.ios/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm index 37db7d68e..205182e51 100644 --- a/com.onesignal.unity.ios/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm +++ b/com.onesignal.unity.ios/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm @@ -71,6 +71,8 @@ - (instancetype) init { [OneSignal.Notifications addPermissionObserver:self]; [OneSignal.Notifications addForegroundLifecycleListener:self]; [OneSignal.Notifications addClickListener:self]; + + _willDisplayEvents = [NSMutableDictionary new]; } return self; @@ -84,10 +86,10 @@ - (void)onNotificationPermissionDidChange:(BOOL)permission { - (void)onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event { if (_willDisplayDelegate != nil) { + _willDisplayEvents[event.notification.notificationId] = event; + NSString *stringNotification = [event.notification stringify]; _willDisplayDelegate([stringNotification UTF8String]); - - _willDisplayEvents[event.notification.notificationId] = event; } } diff --git a/com.onesignal.unity.ios/Runtime/iOSNotificationsManager.cs b/com.onesignal.unity.ios/Runtime/iOSNotificationsManager.cs index 1e27db29a..1b96c9bd2 100644 --- a/com.onesignal.unity.ios/Runtime/iOSNotificationsManager.cs +++ b/com.onesignal.unity.ios/Runtime/iOSNotificationsManager.cs @@ -114,7 +114,7 @@ private static void _onForegroundWillDisplay(string notification) { { // We use Send instead of Post because we need to *not* return to our caller until the // event handlers have returned themselves. This allows a handler to call PreventDefault() - // which will get passed down to Android in InternalNotificationWillDisplayEventArgs. + // which will get passed down to iOS in InternalNotificationWillDisplayEventArgs. UnityMainThreadDispatch.Send(state => handler(_instance, args)); } }