b8ne / react-native-pusher-push-notifications

Manage pusher interest subscriptions and notification events in Javascript.
MIT License
98 stars 86 forks source link

Add incrementBadge option #30

Closed emilkarl closed 5 years ago

emilkarl commented 6 years ago

Not 100% sure about this one but it would be an easy way for people to handle badge counters without having to deal with it in their backend. A use case could be that you push a notification for a new message and the badge counter should go up one for every one of these notifications.

As the Javascript handler won't be run until you open up the application you cannot do this here as you want to badge to update even if the app is in the background or inactive.

One other factor to consider is that you want to push a message to beams with multiple interests. Instead of making one push per user, to have individual badge counters, you can just do one push to Beams with this and it will increment badge number for all subscribers.


The APS data sent to Pusher Beams and then to Apple have an option badge. This will update your apps badge counter to the current number. If you send 1, the badge will show 1. This means you need to handle notification read status in your backend and when pushing update to the current number.

By adding incrementBadge you can increment the badge number without having to deal with your backend.

{
  aps: {
    data: {
      incrementBadge: true
    }
  }
}
moaxaca commented 5 years ago

@emilkarl You are a boss. Ty for this hopefully it gets merged soon!

emilkarl commented 5 years ago

Should we close this or...?

emilkarl commented 5 years ago

Merged it? 🗡

b8ne commented 5 years ago

@emilkarl merging mate. Sorry for taking so long. I know you've put a lot of work into this repo though so happy to give you permissions if you need to keep adding to it?

emilkarl commented 5 years ago

Naa I'm good. I just want to get a good working version with Android support for RN 0.59 up and running ;) Lets make that happen first :)