support subtitle for apple watch.
Signed-off-by: Bo-Yi Wu (吳柏毅) <appleboy.tw@gmail.com>
This commit is contained in:
parent
acd027bdc1
commit
40dabf75c5
|
@ -400,6 +400,7 @@ Request body must has a notifications array. The following is a parameter table
|
|||
|
||||
| name | type | description | required | note |
|
||||
|----------------|------------------|--------------------------------------------------------------------------------------------------|----------|------|
|
||||
| subtitle | string | Apple Watch & Safari display this string as part of the notification interface. | - | |
|
||||
| action | string | The label of the action button. This one is required for Safari Push Notifications. | - | |
|
||||
| action-loc-key | string | If a string is specified, the system displays an alert that includes the Close and View buttons. | - | |
|
||||
| launch-image | string | The filename of an image file in the app bundle, with or without the filename extension. | - | |
|
||||
|
|
|
@ -39,6 +39,7 @@ type Alert struct {
|
|||
LocArgs []string `json:"loc-args,omitempty"`
|
||||
LocKey string `json:"loc-key,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Subtitle string `json:"subtitle,omitempty"`
|
||||
TitleLocArgs []string `json:"title-loc-args,omitempty"`
|
||||
TitleLocKey string `json:"title-loc-key,omitempty"`
|
||||
}
|
||||
|
@ -238,6 +239,11 @@ func iosAlertDictionary(payload *payload.Payload, req PushNotification) *payload
|
|||
payload.AlertTitle(req.Title)
|
||||
}
|
||||
|
||||
// Apple Watch & Safari display this string as part of the notification interface.
|
||||
if len(req.Alert.Subtitle) > 0 {
|
||||
payload.AlertSubtitle(req.Alert.Subtitle)
|
||||
}
|
||||
|
||||
if len(req.Alert.TitleLocKey) > 0 {
|
||||
payload.AlertTitleLocKey(req.Alert.TitleLocKey)
|
||||
}
|
||||
|
|
|
@ -132,6 +132,7 @@ func TestIOSAlertNotificationStructure(t *testing.T) {
|
|||
LaunchImage: test,
|
||||
LocArgs: []string{"a", "b"},
|
||||
LocKey: test,
|
||||
Subtitle: test,
|
||||
TitleLocArgs: []string{"a", "b"},
|
||||
TitleLocKey: test,
|
||||
},
|
||||
|
@ -153,6 +154,7 @@ func TestIOSAlertNotificationStructure(t *testing.T) {
|
|||
launchImage, _ := jsonparser.GetString(data, "aps", "alert", "launch-image")
|
||||
locKey, _ := jsonparser.GetString(data, "aps", "alert", "loc-key")
|
||||
title, _ := jsonparser.GetString(data, "aps", "alert", "title")
|
||||
subtitle, _ := jsonparser.GetString(data, "aps", "alert", "subtitle")
|
||||
titleLocKey, _ := jsonparser.GetString(data, "aps", "alert", "title-loc-key")
|
||||
aps := dat["aps"].(map[string]interface{})
|
||||
alert := aps["alert"].(map[string]interface{})
|
||||
|
@ -165,6 +167,7 @@ func TestIOSAlertNotificationStructure(t *testing.T) {
|
|||
assert.Equal(t, test, launchImage)
|
||||
assert.Equal(t, test, locKey)
|
||||
assert.Equal(t, test, title)
|
||||
assert.Equal(t, test, subtitle)
|
||||
assert.Equal(t, test, titleLocKey)
|
||||
assert.Contains(t, titleLocArgs, "a")
|
||||
assert.Contains(t, titleLocArgs, "b")
|
||||
|
|
Loading…
Reference in New Issue