feat: Add support for the mutable-content flag (#179)
This commit is contained in:
parent
ef9085c4b7
commit
3f4485edf7
|
@ -415,6 +415,7 @@ Request body must has a notifications array. The following is a parameter table
|
|||
| badge | int | badge count | - | only iOS |
|
||||
| category | string | the UIMutableUserNotificationCategory object | - | only iOS |
|
||||
| alert | string array | payload of a iOS message | - | only iOS. See the [detail](#ios-alert-payload) |
|
||||
| mutable_content | bool | enable Notification Service app extension. | - | only iOS(10.0+).
|
||||
|
||||
### iOS alert payload
|
||||
|
||||
|
|
|
@ -74,13 +74,14 @@ type PushNotification struct {
|
|||
Notification gcm.Notification `json:"notification,omitempty"`
|
||||
|
||||
// iOS
|
||||
Expiration int64 `json:"expiration,omitempty"`
|
||||
ApnsID string `json:"apns_id,omitempty"`
|
||||
Topic string `json:"topic,omitempty"`
|
||||
Badge *int `json:"badge,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
URLArgs []string `json:"url-args,omitempty"`
|
||||
Alert Alert `json:"alert,omitempty"`
|
||||
Expiration int64 `json:"expiration,omitempty"`
|
||||
ApnsID string `json:"apns_id,omitempty"`
|
||||
Topic string `json:"topic,omitempty"`
|
||||
Badge *int `json:"badge,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
URLArgs []string `json:"url-args,omitempty"`
|
||||
Alert Alert `json:"alert,omitempty"`
|
||||
MutableContent bool `json:"mutable-content,omitempty"`
|
||||
}
|
||||
|
||||
// CheckMessage for check request message
|
||||
|
@ -314,6 +315,10 @@ func GetIOSNotification(req PushNotification) *apns.Notification {
|
|||
payload.Badge(*req.Badge)
|
||||
}
|
||||
|
||||
if req.MutableContent {
|
||||
payload.MutableContent()
|
||||
}
|
||||
|
||||
if len(req.Sound) > 0 {
|
||||
payload.Sound(req.Sound)
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
|||
Message: message,
|
||||
Sound: test,
|
||||
ContentAvailable: true,
|
||||
MutableContent: true,
|
||||
}
|
||||
|
||||
notification := GetIOSNotification(req)
|
||||
|
@ -151,6 +152,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
|||
badge, _ := jsonparser.GetInt(data, "aps", "badge")
|
||||
sound, _ := jsonparser.GetString(data, "aps", "sound")
|
||||
contentAvailable, _ := jsonparser.GetInt(data, "aps", "content-available")
|
||||
mutableContent, _ := jsonparser.GetInt(data, "aps", "mutable-content")
|
||||
|
||||
if req.Badge != nil {
|
||||
t.Errorf("req.Badge must be nil")
|
||||
|
@ -163,6 +165,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
|||
assert.Equal(t, 0, int(badge))
|
||||
assert.Equal(t, test, sound)
|
||||
assert.Equal(t, 1, int(contentAvailable))
|
||||
assert.Equal(t, 1, int(mutableContent))
|
||||
|
||||
// Add Bage
|
||||
expectBadge := 10
|
||||
|
|
Loading…
Reference in New Issue