Suppo zero value to clear the badge on the app icon.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
40dabf75c5
commit
4b10396093
|
@ -304,7 +304,8 @@ func GetIOSNotification(req PushNotification) *apns.Notification {
|
|||
|
||||
payload := payload.NewPayload().Alert(req.Message)
|
||||
|
||||
if req.Badge > 0 {
|
||||
// zero value for clear the badge on the app icon.
|
||||
if req.Badge >= 0 {
|
||||
payload.Badge(req.Badge)
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestIOSNotificationStructure(t *testing.T) {
|
|||
Expiration: time.Now().Unix(),
|
||||
Priority: "normal",
|
||||
Message: message,
|
||||
Badge: 1,
|
||||
Badge: 0,
|
||||
Sound: test,
|
||||
ContentAvailable: true,
|
||||
Data: D{
|
||||
|
@ -108,7 +108,7 @@ func TestIOSNotificationStructure(t *testing.T) {
|
|||
assert.Equal(t, unix, notification.Expiration.Unix())
|
||||
assert.Equal(t, ApnsPriorityLow, notification.Priority)
|
||||
assert.Equal(t, message, alert)
|
||||
assert.Equal(t, 1, int(badge))
|
||||
assert.Equal(t, 0, int(badge))
|
||||
assert.Equal(t, test, sound)
|
||||
assert.Equal(t, 1, int(contentAvailable))
|
||||
assert.Equal(t, "test", key1)
|
||||
|
|
Loading…
Reference in New Issue