[ci skip] update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
9bc2df6baa
commit
dab1d73149
67
README.md
67
README.md
|
@ -289,6 +289,73 @@ Add other fields which user defined via `data` field.
|
|||
]
|
||||
```
|
||||
|
||||
### Android Example
|
||||
|
||||
Send normal notification.
|
||||
|
||||
```json
|
||||
"notifications": [
|
||||
{
|
||||
"tokens": ["token_a", "token_b"],
|
||||
"platform": 2,
|
||||
"message": "Hello World Android!",
|
||||
"title": "You got message"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Add `notification` payload.
|
||||
|
||||
```json
|
||||
"notifications": [
|
||||
{
|
||||
"tokens": ["token_a", "token_b"],
|
||||
"platform": 2,
|
||||
"message": "Hello World Android!",
|
||||
"title": "You got message",
|
||||
"notification" : {
|
||||
"icon": "myicon",
|
||||
"color": "#112244"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Add other fields which user defined via `data` field.
|
||||
|
||||
```json
|
||||
"notifications": [
|
||||
{
|
||||
"tokens": ["token_a", "token_b"],
|
||||
"platform": 2,
|
||||
"message": "Hello World Android!",
|
||||
"title": "You got message",
|
||||
"data": {
|
||||
"Nick" : "Mario",
|
||||
"body" : "great match!",
|
||||
"Room" : "PortugalVSDenmark"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Response body
|
||||
|
||||
Error response message table:
|
||||
|
||||
|status code|message|
|
||||
|-------|-------|
|
||||
|400|Missing `notifications` field.|
|
||||
|400|Notifications field is empty.|
|
||||
|400|Number of notifications(50) over limit(10)|
|
||||
|
||||
Success response:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": "ok"
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func pushHandler(c *gin.Context) {
|
|||
}
|
||||
|
||||
if len(form.Notifications) == 0 {
|
||||
msg = "Notification field is empty."
|
||||
msg = "Notifications field is empty."
|
||||
LogAccess.Debug(msg)
|
||||
AbortWithError(c, http.StatusBadRequest, msg)
|
||||
return
|
||||
|
@ -51,7 +51,7 @@ func pushHandler(c *gin.Context) {
|
|||
go SendNotification(form)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"text": "Welcome to notification server.",
|
||||
"success": "ok",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue