Skip to content

Commit 5c6f6a6

Browse files
committed
Add CollapseID to update an already sent push notification.
1 parent a9e6c00 commit 5c6f6a6

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

apns/apns.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
)
1818

1919
type PushMessage struct {
20+
Id string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty" query:"id,omitempty"`
2021
DeviceToken string `form:"-" json:"-" xml:"-" query:"-"`
2122
DeviceKey string `form:"device_key,omitempty" json:"device_key,omitempty" xml:"device_key,omitempty" query:"device_key,omitempty"`
2223
Subtitle string `form:"subtitle,omitempty" json:"subtitle,omitempty" xml:"subtitle,omitempty" query:"subtitle,omitempty"`
@@ -115,6 +116,7 @@ func Push(msg *PushMessage) error {
115116
clients <- client // add the client back to the pool
116117

117118
resp, err := client.Push(&apns2.Notification{
119+
CollapseID: msg.Id,
118120
DeviceToken: msg.DeviceToken,
119121
Topic: topic,
120122
Payload: pl.MutableContent(),

route_push.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ func push(params map[string]interface{}) (int, error) {
217217
switch val := val.(type) {
218218
case string:
219219
switch strings.ToLower(string(key)) {
220+
case "id":
221+
msg.Id = val
220222
case "device_key":
221223
msg.DeviceKey = val
222224
case "subtitle":

0 commit comments

Comments
 (0)