Skip to content

Omitting Badge count in payload results in Badge set to -1 #47

@nikolasborrel

Description

@nikolasborrel

Omitting the badge count in payload sets the badge count to -1 after adding payload. This is problematic if the notification should be silent, setting 'content-available' to 1 as stated by Apple:

"For a silent notification, take care to ensure there is no alert, sound, or badge payload in the aps dictionary. If you don’t follow this guidance, the incorrectly-configured notification might be throttled and not delivered to the app in the background, and instead of being silent is displayed to the user."

The hack in the following function is introducing the issue:

func (pn *PushNotification) AddPayload(p *Payload) {
...
// Still a hack though :)
if p.Badge == 0 {
p.Badge = -1
}
pn.Set("aps", p)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions