diff --git a/README.md b/README.md index 07f726f..bf00fc6 100644 --- a/README.md +++ b/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 diff --git a/gorush/server.go b/gorush/server.go index e5ea23b..49167c2 100644 --- a/gorush/server.go +++ b/gorush/server.go @@ -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", }) }