Coccodrillo / apns

A Golang package for sending Apple Push Notifications and using the Feedback Service.
MIT License
433 stars 126 forks source link

Don't send badge value #22

Open MrTravisB opened 10 years ago

MrTravisB commented 10 years ago

Is it currently possible to not send a value for badge count? It seems to be the badge count is always sent since when it isn't explicitly set to something the library sets it to -1. I realize the issue here is differentiating between an empty badge count and a badge count set to zero. Two possible solutions would be to either make badge count an int pointer or create a method/flag on the payload that signals that the user wants to exclude the badge count. Thoughts?

draaglom commented 10 years ago

I think I prefer the int pointer version. @anachronistic, what about you?

joekarl commented 9 years ago

A third option exists which would be to treat badge numbers as such:

Just would need to heavily document that if you want to clear the badge number, you should set the badge to < 0 rather than 0.

This doesn't match one to one with Apple's spec but would alleviate the issue without changing the Payload interface.

joekarl commented 9 years ago

As an update, ended up going with a typed solution and implementing json Marshaller interface (https://github.com/joekarl/go-libapns/blob/ccef56a3e7cb9f0f0da4add6da007a23ad0da46d/badge_number.go) props to @themartorana for that one