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

IOS: Badge triggered notifications #324

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi

In the documentation we see that the delivered event is not fired for triggered notifications. How can we increase the badge count for triggered notifications?

Thank you!

helenaford commented 3 years ago

Unfortunately, there's no way to change the badge count automatically when a trigger notification is displayed. iOS gives you the option to change the badge count with the notification payload but it's not possible to dynamically increase/decrease it.

mars-lan commented 3 years ago

Can we reopen this as a doc fix? The example here is not working given that EventType.DELIVERED is not triggered when the app is running in background or killed.

helenaford commented 3 years ago

@mars-lan good spot. Will update

helenaford commented 3 years ago

Example updated https://notifee.app/react-native/docs/ios/badges#integration

mars-lan commented 3 years ago

@helenaford was the new doc published? I didn't seem to spot any difference in https://notifee.app/react-native/docs/ios/badges#integration.

helenaford commented 3 years ago

@mars-lan here's the diff https://github.com/notifee/documentation/commit/668881e68dc2a001bb1474416f12b63860ed2e61.

I swapped out the example that used trigger notifications with an example of when a remote notification is delivered in the background, you may want to adjust the badge count, and then when the user interacts with the notification, decrease it again.

The original example as you pointed out to us was not feasible. The new example I used, I think, is a pretty common scenario. But, open to suggestions 😅

mars-lan commented 3 years ago

Got it. I think you should also add a note saying that this will only work if the app is running (in either fg or bg). In other words notifee.onBackgroundEvent won't get called if it's a cold launch. Or did I misunderstand it?