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 |
|
| badge | int | badge count | - | only iOS |
|
||||||
| category | string | the UIMutableUserNotificationCategory object | - | 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) |
|
| 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
|
### iOS alert payload
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ type PushNotification struct {
|
||||||
Category string `json:"category,omitempty"`
|
Category string `json:"category,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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckMessage for check request message
|
// CheckMessage for check request message
|
||||||
|
@ -314,6 +315,10 @@ func GetIOSNotification(req PushNotification) *apns.Notification {
|
||||||
payload.Badge(*req.Badge)
|
payload.Badge(*req.Badge)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.MutableContent {
|
||||||
|
payload.MutableContent()
|
||||||
|
}
|
||||||
|
|
||||||
if len(req.Sound) > 0 {
|
if len(req.Sound) > 0 {
|
||||||
payload.Sound(req.Sound)
|
payload.Sound(req.Sound)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
Message: message,
|
Message: message,
|
||||||
Sound: test,
|
Sound: test,
|
||||||
ContentAvailable: true,
|
ContentAvailable: true,
|
||||||
|
MutableContent: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
notification := GetIOSNotification(req)
|
notification := GetIOSNotification(req)
|
||||||
|
@ -151,6 +152,7 @@ func TestSendZeroValueForBadgeKey(t *testing.T) {
|
||||||
badge, _ := jsonparser.GetInt(data, "aps", "badge")
|
badge, _ := jsonparser.GetInt(data, "aps", "badge")
|
||||||
sound, _ := jsonparser.GetString(data, "aps", "sound")
|
sound, _ := jsonparser.GetString(data, "aps", "sound")
|
||||||
contentAvailable, _ := jsonparser.GetInt(data, "aps", "content-available")
|
contentAvailable, _ := jsonparser.GetInt(data, "aps", "content-available")
|
||||||
|
mutableContent, _ := jsonparser.GetInt(data, "aps", "mutable-content")
|
||||||
|
|
||||||
if req.Badge != nil {
|
if req.Badge != nil {
|
||||||
t.Errorf("req.Badge must be 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, 0, int(badge))
|
||||||
assert.Equal(t, test, sound)
|
assert.Equal(t, test, sound)
|
||||||
assert.Equal(t, 1, int(contentAvailable))
|
assert.Equal(t, 1, int(contentAvailable))
|
||||||
|
assert.Equal(t, 1, int(mutableContent))
|
||||||
|
|
||||||
// Add Bage
|
// Add Bage
|
||||||
expectBadge := 10
|
expectBadge := 10
|
||||||
|
|
Loading…
Reference in New Issue