Skip to content

[Bug]: event.preventDefault() doesn't work on iOS #1592

@kamil-floqsta

Description

@kamil-floqsta

What happened?

I would like to not display notification if some conditions are met.

Regarding to the [User Model] Rename Events & API Changes pull request:

OneSignal.Notifications.addEventListener('foregroundWillDisplay', (event) => {
      event.preventDefault();
      // async work
      event.getNotifications.display();
};

In the previous versions this could to achived by calling notificationReceivedEvent.complete(undefined)

Steps to reproduce?

1. Install react-native-onesignal 5.0.2
2. Build and run iOS
3. Subscribe user to the push notifications with OneSignal SDK
4. Add foregroundWillDisplay event listener and comment `event.getNotifications.display()`
5. Send test notification
6. The notification is displayed but should be hidden

What did you expect to happen?

I would like to not display notification if some conditions are met.

React Native OneSignal SDK version

5.0.2

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions