Add CollapseID for ios notification. (#308)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
b7b9cd22dd
commit
bd6a6f7eba
|
@ -76,6 +76,7 @@ type PushNotification struct {
|
|||
// iOS
|
||||
Expiration int64 `json:"expiration,omitempty"`
|
||||
ApnsID string `json:"apns_id,omitempty"`
|
||||
CollapseID string `json:"collapse_id,omitempty"`
|
||||
Topic string `json:"topic,omitempty"`
|
||||
Badge *int `json:"badge,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
|
|
|
@ -125,8 +125,9 @@ func iosAlertDictionary(payload *payload.Payload, req PushNotification) *payload
|
|||
// ref: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1
|
||||
func GetIOSNotification(req PushNotification) *apns2.Notification {
|
||||
notification := &apns2.Notification{
|
||||
ApnsID: req.ApnsID,
|
||||
Topic: req.Topic,
|
||||
ApnsID: req.ApnsID,
|
||||
Topic: req.Topic,
|
||||
CollapseID: req.CollapseID,
|
||||
}
|
||||
|
||||
if req.Expiration > 0 {
|
||||
|
|
|
@ -180,6 +180,7 @@ func TestCheckSilentNotification(t *testing.T) {
|
|||
req := PushNotification{
|
||||
ApnsID: test,
|
||||
Topic: test,
|
||||
CollapseID: test,
|
||||
Priority: "normal",
|
||||
ContentAvailable: true,
|
||||
}
|
||||
|
@ -194,6 +195,9 @@ func TestCheckSilentNotification(t *testing.T) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
assert.Equal(t, test, notification.CollapseID)
|
||||
assert.Equal(t, test, notification.ApnsID)
|
||||
assert.Equal(t, test, notification.Topic)
|
||||
assert.Nil(t, dat["aps"].(map[string]interface{})["alert"])
|
||||
assert.Nil(t, dat["aps"].(map[string]interface{})["sound"])
|
||||
assert.Nil(t, dat["aps"].(map[string]interface{})["badge"])
|
||||
|
|
Loading…
Reference in New Issue