support android `to` parameter.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-03-25 17:56:09 +08:00
parent 875849a111
commit 79dace4485
2 changed files with 5 additions and 3 deletions

View File

@ -27,7 +27,7 @@ func pushHandler(c *gin.Context) {
if err := c.BindJSON(&form); err != nil { if err := c.BindJSON(&form); err != nil {
log.Println(err) log.Println(err)
AbortWithError(c, http.StatusBadRequest, "Missing some parameters like token or platform or message") AbortWithError(c, http.StatusBadRequest, "Bad input request, please refer to README guide.")
return return
} }

View File

@ -34,6 +34,7 @@ type RequestPushNotification struct {
ContentAvailable bool `json:"content_available,omitempty"` ContentAvailable bool `json:"content_available,omitempty"`
// Android // Android
To string `json:"to,omitempty"`
CollapseKey string `json:"collapse_key,omitempty"` CollapseKey string `json:"collapse_key,omitempty"`
DelayWhileIdle bool `json:"delay_while_idle,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"`
TimeToLive uint `json:"time_to_live,omitempty"` TimeToLive uint `json:"time_to_live,omitempty"`
@ -53,6 +54,7 @@ type RequestPushNotification struct {
URLArgs []string `json:"url-args,omitempty"` URLArgs []string `json:"url-args,omitempty"`
Extend []ExtendJSON `json:"extend,omitempty"` Extend []ExtendJSON `json:"extend,omitempty"`
Alert alert `json:"alert,omitempty"` Alert alert `json:"alert,omitempty"`
// meta // meta
IDs []uint64 `json:"seq_id,omitempty"` IDs []uint64 `json:"seq_id,omitempty"`
} }
@ -192,8 +194,8 @@ func pushNotificationAndroid(req RequestPushNotification) bool {
notification.RegistrationIds = req.Tokens notification.RegistrationIds = req.Tokens
if len(req.Topic) > 0 { if len(req.To) > 0 {
notification.To = req.Topic notification.To = req.To
} }
if len(req.Priority) > 0 && req.Priority == "high" { if len(req.Priority) > 0 && req.Priority == "high" {