Added support for iOS13 with apns-push-type (#424)

This commit is contained in:
Emmet McPoland 2019-09-23 16:36:38 +01:00 committed by Bo-Yi Wu
parent 3812d357fd
commit 1c82f5c904
4 changed files with 7 additions and 1 deletions

View File

@ -538,6 +538,7 @@ Request body must has a notifications array. The following is a parameter table
| notification | string array | payload of a FCM message | - | only Android. See the [detail](#android-notification-payload) |
| expiration | int | expiration for notification | - | only iOS |
| apns_id | string | A canonical UUID that identifies the notification | - | only iOS |
| push_type | string | The type of the notification. The value of this header is alert or background. | - | only iOS |
| 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) |

2
go.mod
View File

@ -19,7 +19,7 @@ require (
github.com/mattn/go-isatty v0.0.8
github.com/mitchellh/mapstructure v1.1.2
github.com/prometheus/client_golang v1.0.0
github.com/sideshow/apns2 v0.16.0
github.com/sideshow/apns2 v0.19.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.3.0

View File

@ -82,6 +82,7 @@ type PushNotification struct {
ApnsID string `json:"apns_id,omitempty"`
CollapseID string `json:"collapse_id,omitempty"`
Topic string `json:"topic,omitempty"`
PushType string `json:"push_type,omitempty"`
Badge *int `json:"badge,omitempty"`
Category string `json:"category,omitempty"`
ThreadID string `json:"thread-id,omitempty"`

View File

@ -183,6 +183,10 @@ func GetIOSNotification(req PushNotification) *apns2.Notification {
notification.Priority = apns2.PriorityLow
}
if len(req.PushType) > 0 {
notification.PushType = apns2.EPushType(req.PushType)
}
payload := payload.NewPayload()
// add alert object if message length > 0