invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
465 stars 31 forks source link

[Question] Is there a way to intercept conditionaly notification ? #277

Closed Nevosis closed 3 years ago

Nevosis commented 3 years ago

Hello.

I'd like to display conditionaly a notification that has already been created. Is there a way to intercept a notification before its getting triggered (may it be foreground or background ?)

Thanks

helenaford commented 3 years ago

Hi, is this for iOS or Android or both?

When you say you'd like to intercept it before it's triggered, sadly there's no way for us to know when it will be displayed. Maybe there could be something custom we could do on Android (but that's a maybe, we'd have to look into it more). Have you explored any ways to do this on the server or in your app on the javascript-side? I understand the server change depends on your setup.

It's an interesting scenario 🤔

Nevosis commented 3 years ago

Thanks for answering. It ideally is for both (and may interest other users). To provide more information, we use notifee as a local service without FCM so there is no way to do this "on the server". The goal is to show a notification to remind user to do a task, but if he's currently doind the task, I'd like not to notify him. An alternative could be to not show the notification if the app is in foreground.

In the javascript side, the only way I found was to delete the notification and re-create it later conditionaly, but its far from optimum.

I'm not really experienced in natives operation on notification so I can't really add anything about android or Ios :s

helenaford commented 3 years ago

Ah yeah, I was going to say that was the only thing you could do right now, is to update the notification once it's displayed (but that is only possible with android).

Nevosis commented 3 years ago

Thank you, We're gonna do the workaround to remove notification when the user does the task and to create a new one later on :)