Giter Site home page Giter Site logo

[Bug]: Duplicate notifications occur when using an additional SDK, and foregroundWillDisplay does not fire with notifications from sources outside of OneSignal. about react-native-onesignal HOT 2 OPEN

marcin-piela-800 avatar marcin-piela-800 commented on June 23, 2024
[Bug]: Duplicate notifications occur when using an additional SDK, and foregroundWillDisplay does not fire with notifications from sources outside of OneSignal.

from react-native-onesignal.

Comments (2)

jennantilla avatar jennantilla commented on June 23, 2024

Hi @marcin-piela-800 thanks for reaching out! Just to make sure I understand, only the notifications from the other push provider display? If so, that is what I would expect as our methods are meant to handle OneSignal notifications.

I'll look a bit deeper at the logic and see if there is anything we can tweak to handle notifications not coming from OneSignal.

Thanks

from react-native-onesignal.

marcin-piela-800 avatar marcin-piela-800 commented on June 23, 2024

I implemented the following method in AppDelegate.mm:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  NSDictionary *userInfo = notification.request.content.userInfo;
  NSString *customValue = userInfo[@"custom"]; // Added only by OneSignal
  
  if (customValue != nil) {
      completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
  } else {
      completionHandler(UNNotificationPresentationOptionNone);
  }
}

Now, I'm able to prevent notifications (other than OneSignal notifications) from being displayed when the app is in the focused state.

The problem is that it's not default behavior to show all notifications when app is focused, it's added by OneSignal so I would expect to be able to do smth with it using JS code (listener from OneSignal package)

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.