Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #73 from timakin/feature/unnotification-category
Browse files Browse the repository at this point in the history
Add UNNotificationCategory option for iOS.
  • Loading branch information
cubicdaiya authored Aug 7, 2017
2 parents 66c5159 + 26a8879 commit 14e46cb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The JSON below is the request-body example.
"title": "Greeting",
"subtitle": "greeting",
"badge" : 1,
"category": "category1",
"sound" : "default",
"content_available" : false,
"mutable_content" : false,
Expand Down Expand Up @@ -58,6 +59,7 @@ The request-body must has the `notifications` array. There is the parameter tabl
|title |string |title for notification |- | |only iOS |
|subtitle |string |subtitle for notification |- | |only iOS |
|badge |int |badge count |- |0 |only iOS |
|category |string |unnotification category |- | |only iOS |
|sound |string |sound type |- | |only iOS |
|expiry |int |expiration for notification |- |0 |only iOS. |
|content_available|bool |indicate that new content is available |- |false |only iOS. |
Expand Down
1 change: 1 addition & 0 deletions cmd/gaurun_recover/gaurun_recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func main() {
Title: logPush.Title,
Subtitle: logPush.Subtitle,
Badge: logPush.Badge,
Category: logPush.Category,
Sound: logPush.Sound,
ContentAvailable: logPush.ContentAvailable,
Expiry: logPush.Expiry,
Expand Down
1 change: 1 addition & 0 deletions gaurun/apns_http2.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{}
p := payload.APS{
Alert: payload.Alert{Title: req.Title, Body: req.Message, Subtitle: req.Subtitle},
Badge: badge.New(uint(req.Badge)),
Category: req.Category,
Sound: req.Sound,
ContentAvailable: req.ContentAvailable,
MutableContent: req.MutableContent,
Expand Down
6 changes: 6 additions & 0 deletions gaurun/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type LogPushEntry struct {
Title string `json:"title,omitempty"`
Subtitle string `json:"subtitle,omitempty"`
Badge int `json:"badge,omitempty"`
Category string `json:"category,omitempty"`
Sound string `json:"sound,omitempty"`
ContentAvailable bool `json:"content_available,omitempty"`
MutableContent bool `json:"mutable_content,omitempty"`
Expand Down Expand Up @@ -161,6 +162,10 @@ func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNo
if req.Badge != 0 {
badge = zap.Int("badge", req.Badge)
}
category := zap.Skip()
if req.Category != "" {
category = zap.String("category", req.Category)
}
sound := zap.Skip()
if req.Sound != "" {
sound = zap.String("sound", req.Sound)
Expand Down Expand Up @@ -191,6 +196,7 @@ func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNo
title,
subtitle,
badge,
category,
sound,
contentAvailable,
mutableContent,
Expand Down
1 change: 1 addition & 0 deletions gaurun/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type RequestGaurunNotification struct {
Title string `json:"title,omitempty"`
Subtitle string `json:"subtitle,omitempty"`
Badge int `json:"badge,omitempty"`
Category string `json:"category,omitempty"`
Sound string `json:"sound,omitempty"`
ContentAvailable bool `json:"content_available,omitempty"`
MutableContent bool `json:"mutable_content,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions samples/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type RequestGaurunNotification struct {
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Badge int `json:"badge"`
Category string `json:"category"`
Sound string `json:"sound"`
ContentAvailable bool `json:"content_available"`
Expiry int `json:"expiry"`
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
req.Notifications[i].Title = "Greeting"
req.Notifications[i].Subtitle = "greeting"
req.Notifications[i].Badge = 1
req.Notifications[i].Category = "category1"
req.Notifications[i].Sound = "default"
req.Notifications[i].ContentAvailable = true
i++
Expand Down

0 comments on commit 14e46cb

Please sign in to comment.