Pr0Ger / PyAPNs2

Python library for interacting with the Apple Push Notification service (APNs) via HTTP/2 protocol
MIT License
349 stars 179 forks source link

Fix determination of push type for empty notifications with badge 0 #109

Closed cassidylaidlaw closed 4 years ago

cassidylaidlaw commented 4 years ago

Without this change, it is impossible to send an empty notification that just sets the app badge to 0 (removes the badge). If notification.badge is 0, then APNsClient.send_notification_async will calculate the push type as background, which will not update the badge number. The solution is to compare notification.badge explicitly to None.

Pr0Ger commented 4 years ago

@cassidylaidlaw Thanks for contribution.

Btw, send_notification_async()/send_notification_batch() has param push_type to override this inferring. Dunno why it's not exposed in send_notification() method, I'll fix it in next release

cassidylaidlaw commented 4 years ago

Thanks for merging!