support webpush with link
This commit is contained in:
parent
4b7991bbbf
commit
2b543fa47c
3
model.go
3
model.go
|
@ -17,6 +17,7 @@ type PushRequest struct {
|
|||
Label string `json:"label,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
Sound *Sound `json:"sound,omitempty"`
|
||||
Link string `json:"link"` // for webpush
|
||||
}
|
||||
|
||||
// Sound ...
|
||||
|
@ -31,6 +32,7 @@ type PushResponse struct {
|
|||
}
|
||||
|
||||
type pushRequest struct {
|
||||
Version string `json:"version"`
|
||||
APIKey string `json:"apiKey"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
|
@ -41,6 +43,7 @@ type pushRequest struct {
|
|||
Label string `json:"label"`
|
||||
Category string `json:"category"`
|
||||
Sound *Sound `json:"sound,omitempty"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
// Query ...
|
||||
|
|
|
@ -8,6 +8,9 @@ import (
|
|||
"github.com/Selly-Modules/natsio"
|
||||
)
|
||||
|
||||
// version specify current version of client
|
||||
const version = "1.0.2"
|
||||
|
||||
const (
|
||||
SendByTopic = "topic"
|
||||
SendByUsers = "users"
|
||||
|
@ -53,6 +56,7 @@ func NewClient(cfg Config) (*Client, error) {
|
|||
// PushToUsers push notification to list user id
|
||||
func (c *Client) PushToUsers(payload PushRequest) (requestID string, err error) {
|
||||
p := pushRequest{
|
||||
Version: version,
|
||||
APIKey: c.Config.APIKey,
|
||||
Title: payload.Title,
|
||||
Body: payload.Body,
|
||||
|
@ -62,6 +66,7 @@ func (c *Client) PushToUsers(payload PushRequest) (requestID string, err error)
|
|||
Label: payload.Label,
|
||||
Category: payload.Category,
|
||||
Sound: payload.Sound,
|
||||
Link: payload.Link,
|
||||
}
|
||||
msg, err := c.natsServer.Request(SubjectPushNotification, toBytes(p))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue