feat: Add ThreadID for apns (#326)
This commit is contained in:
parent
6540d16e3e
commit
230cfb23fa
|
@ -80,6 +80,7 @@ type PushNotification struct {
|
||||||
Topic string `json:"topic,omitempty"`
|
Topic string `json:"topic,omitempty"`
|
||||||
Badge *int `json:"badge,omitempty"`
|
Badge *int `json:"badge,omitempty"`
|
||||||
Category string `json:"category,omitempty"`
|
Category string `json:"category,omitempty"`
|
||||||
|
ThreadID string `json:"thread-id,omitempty"`
|
||||||
URLArgs []string `json:"url-args,omitempty"`
|
URLArgs []string `json:"url-args,omitempty"`
|
||||||
Alert Alert `json:"alert,omitempty"`
|
Alert Alert `json:"alert,omitempty"`
|
||||||
MutableContent bool `json:"mutable-content,omitempty"`
|
MutableContent bool `json:"mutable-content,omitempty"`
|
||||||
|
|
|
@ -166,6 +166,10 @@ func GetIOSNotification(req PushNotification) *apns2.Notification {
|
||||||
payload.URLArgs(req.URLArgs)
|
payload.URLArgs(req.URLArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(req.ThreadID) > 0 {
|
||||||
|
payload.ThreadID(req.ThreadID)
|
||||||
|
}
|
||||||
|
|
||||||
for k, v := range req.Data {
|
for k, v := range req.Data {
|
||||||
payload.Custom(k, v)
|
payload.Custom(k, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
Sound: test,
|
Sound: test,
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
MutableContent: true,
|
MutableContent: true,
|
||||||
|
ThreadID: test,
|
||||||
}
|
}
|
||||||
|
|
||||||
notification := GetIOSNotification(req)
|
notification := GetIOSNotification(req)
|
||||||
|
@ -130,6 +131,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
alert, _ := jsonparser.GetString(data, "aps", "alert")
|
alert, _ := jsonparser.GetString(data, "aps", "alert")
|
||||||
badge, _ := jsonparser.GetInt(data, "aps", "badge")
|
badge, _ := jsonparser.GetInt(data, "aps", "badge")
|
||||||
sound, _ := jsonparser.GetString(data, "aps", "sound")
|
sound, _ := jsonparser.GetString(data, "aps", "sound")
|
||||||
|
threadID, _ := jsonparser.GetString(data, "aps", "thread-id")
|
||||||
contentAvailable, _ := jsonparser.GetInt(data, "aps", "content-available")
|
contentAvailable, _ := jsonparser.GetInt(data, "aps", "content-available")
|
||||||
mutableContent, _ := jsonparser.GetInt(data, "aps", "mutable-content")
|
mutableContent, _ := jsonparser.GetInt(data, "aps", "mutable-content")
|
||||||
|
|
||||||
|
@ -143,6 +145,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
assert.Equal(t, message, alert)
|
assert.Equal(t, message, alert)
|
||||||
assert.Equal(t, 0, int(badge))
|
assert.Equal(t, 0, int(badge))
|
||||||
assert.Equal(t, test, sound)
|
assert.Equal(t, test, sound)
|
||||||
|
assert.Equal(t, test, threadID)
|
||||||
assert.Equal(t, 1, int(contentAvailable))
|
assert.Equal(t, 1, int(contentAvailable))
|
||||||
assert.Equal(t, 1, int(mutableContent))
|
assert.Equal(t, 1, int(mutableContent))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue