Giter Site home page Giter Site logo

Comments (5)

emawby avatar emawby commented on September 25, 2024

@kamil-floqsta In order to not display the notification you just call event.preventDefault();
If you would then like to display the notification after delaying the default display you call event.getNotifications.display();
If you never want to show the notification do not call display

from react-native-onesignal.

kamil-floqsta avatar kamil-floqsta commented on September 25, 2024

@kamil-floqsta In order to not display the notification you just call event.preventDefault();
If you would then like to display the notification after delaying the default display you call event.getNotifications.display();
If you never want to show the notification do not call display

@emawby Unfortunately it doesn't work. Here is a code sample:

OneSignal.Notifications.addEventListener(
    'foregroundWillDisplay',
    (notificationReceivedEvent: NotificationWillDisplayEvent) => {
      const notification = notificationReceivedEvent.getNotification();
        if (
          // some condition
        ) {
          notificationReceivedEvent.preventDefault();
          return;
        }
      }
      notification.display();
      }
  );

The listener receives a notification, then notificationReceivedEvent.preventDefault() is called but after about ~10 seconds the notification is displayed anyway.

from react-native-onesignal.

kamil-floqsta avatar kamil-floqsta commented on September 25, 2024

@emawby I turned on logs with LogLevel.Verbose
And here is the Xcode outcome for the notification with preventDefault():

2023-10-26 21:32:17.300081+0200 PROJECT_NAME[85270:18154602] VERBOSE: OSNotificationWillDisplayEvent.preventDefault called.

2023-10-26 21:32:42.256768+0200 PROJECT_NAME[85270:18154435] WARNING: OSNotificationLifecycleListener:onWillDisplayNotification timed out. Display was not called within 25.000000 seconds. Continue with display notification: 0
2023-10-26 21:32:42.263611+0200 PROJECT_NAME[85270:18154435] VERBOSE: finishProcessingNotification: Fired!
2023-10-26 21:32:42.263806+0200 PROJECT_NAME[85270:18154435] VERBOSE: Notification display type: 0
2023-10-26 21:32:42.264041+0200 PROJECT_NAME[85270:18154435] VERBOSE: notificationReceived called! opened: NO
2023-10-26 21:32:42.264601+0200 PROJECT_NAME[85270:18154435] VERBOSE: finishProcessingNotification: call completionHandler with options: 0

from react-native-onesignal.

kamil-floqsta avatar kamil-floqsta commented on September 25, 2024

@emawby Even if e. preventDefault() is removed the loggs says it was called:

2023-10-27 12:10:15.873749+0200 PROJECT_NAME[86156:18319475] VERBOSE: OSNotificationWillDisplayEvent.preventDefault called.

from react-native-onesignal.

rpinto18 avatar rpinto18 commented on September 25, 2024

@kamil-floqsta hello, any solution?

from react-native-onesignal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.