Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send badge value #22

Open
MrTravisB opened this issue Sep 10, 2014 · 3 comments
Open

Don't send badge value #22

MrTravisB opened this issue Sep 10, 2014 · 3 comments

Comments

@MrTravisB
Copy link
Contributor

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
Copy link
Collaborator

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

@joekarl
Copy link

joekarl commented Jan 13, 2015

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

  • badge == 0 - omit
  • badge > 0 - set badge number
  • badge < 0 - set badge number to -1 (which Apple treats as 0 on their end)

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
Copy link

joekarl commented Feb 14, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants