From e9e378bf9c450b3111d8155b7e50b042117cc7ba Mon Sep 17 00:00:00 2001 From: timakin Date: Mon, 3 Jul 2017 20:23:07 +0900 Subject: [PATCH 1/5] Title and Subtitle parameter for the iOS (>=ver10) notification setting --- gaurun/apns_http2.go | 2 +- gaurun/notification.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gaurun/apns_http2.go b/gaurun/apns_http2.go index 95d3d65..c126e0d 100644 --- a/gaurun/apns_http2.go +++ b/gaurun/apns_http2.go @@ -69,7 +69,7 @@ func NewApnsServiceHttp2(client *http.Client) *push.Service { func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{} { p := payload.APS{ - Alert: payload.Alert{Body: req.Message}, + Alert: payload.Alert{Title: req.Title, Body: req.Message, Subtitle: req.Subtitle}, Badge: badge.New(uint(req.Badge)), Sound: req.Sound, ContentAvailable: req.ContentAvailable, diff --git a/gaurun/notification.go b/gaurun/notification.go index da35ae6..551c632 100644 --- a/gaurun/notification.go +++ b/gaurun/notification.go @@ -29,6 +29,8 @@ type RequestGaurunNotification struct { DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` // iOS + Title string `json:"title,omitempty"` + Subtitle string `json:"subtitle,omitempty"` Badge int `json:"badge,omitempty"` Sound string `json:"sound,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` From f8d6d14d2252cc4daa6b76ff788b37316db13029 Mon Sep 17 00:00:00 2001 From: timakin Date: Mon, 3 Jul 2017 21:19:34 +0900 Subject: [PATCH 2/5] samples and logger params --- cmd/gaurun_recover/gaurun_recover.go | 2 ++ gaurun/log.go | 12 ++++++++++++ samples/client.go | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/cmd/gaurun_recover/gaurun_recover.go b/cmd/gaurun_recover/gaurun_recover.go index 06d7f71..bcd48e4 100644 --- a/cmd/gaurun_recover/gaurun_recover.go +++ b/cmd/gaurun_recover/gaurun_recover.go @@ -187,6 +187,8 @@ func main() { CollapseKey: logPush.CollapseKey, DelayWhileIdle: logPush.DelayWhileIdle, TimeToLive: logPush.TimeToLive, + Title: logPush.Title, + Subtitle: logPush.Subtitle, Badge: logPush.Badge, Sound: logPush.Sound, ContentAvailable: logPush.ContentAvailable, diff --git a/gaurun/log.go b/gaurun/log.go index f81044d..2524e9b 100644 --- a/gaurun/log.go +++ b/gaurun/log.go @@ -35,6 +35,8 @@ type LogPushEntry struct { DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` // iOS + Title string `json:"title,omitempty"` + Subtitle string `json:"subtitle,omitempty"` Badge int `json:"badge,omitempty"` Sound string `json:"sound,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` @@ -147,6 +149,14 @@ func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNo if req.TimeToLive != 0 { timeToLive = zap.Int("time_to_live", req.TimeToLive) } + title := zap.Skip() + if req.Title != "" { + title = zap.String("title", req.Title) + } + subtitle := zap.Skip() + if req.Subtitle != "" { + subtitle = zap.String("subtitle", req.Subtitle) + } badge := zap.Skip() if req.Badge != 0 { badge = zap.Int("badge", req.Badge) @@ -178,6 +188,8 @@ func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNo collapseKey, delayWhileIdle, timeToLive, + title, + subtitle, badge, sound, contentAvailable, diff --git a/samples/client.go b/samples/client.go index f373a35..caddce7 100644 --- a/samples/client.go +++ b/samples/client.go @@ -24,6 +24,8 @@ type RequestGaurunNotification struct { DelayWhileIdle bool `json:"data_while_idle"` TimeToLive int `json:"time_to_live"` // iOS + Title string `json:"title"` + Subtitle string `json:"subtitle"` Badge int `json:"badge"` Sound string `json:"sound"` ContentAvailable bool `json:"content_available"` @@ -57,7 +59,9 @@ func main() { if *iOSToken != "" { req.Notifications[i].Tokens = append(req.Notifications[i].Tokens, *iOSToken) req.Notifications[i].Platform = 1 + req.Notifications[i].Title = "Greeting" req.Notifications[i].Message = "Hello, iOS!" + req.Notifications[i].Subtitle = "greeting" req.Notifications[i].Badge = 1 req.Notifications[i].Sound = "default" req.Notifications[i].ContentAvailable = true From 8c43b50c55a28633624726776081c1a3f387d836 Mon Sep 17 00:00:00 2001 From: timakin Date: Tue, 4 Jul 2017 08:03:29 +0900 Subject: [PATCH 3/5] Spec for params --- SPEC.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SPEC.md b/SPEC.md index bc4eb24..357c316 100644 --- a/SPEC.md +++ b/SPEC.md @@ -37,7 +37,9 @@ The JSON below is the request-body example. { "token" : ["yyy"], "platform" : 2, + "title": "Greeting", "message" : "Hello, Android!", + "subtitle": "greeting", "collapse_key" : "update", "delay_while_idle" : true, "time_to_live" : 10 @@ -52,7 +54,9 @@ The request-body must has the `notifications` array. There is the parameter tabl |-----------------|------------|-----------------------------------------|--------|-------|----------------| |token |string array|device tokens |o | | | |platform |int |platform(iOS,Android) |o | |1=iOS, 2=Android| +|title |string |title for notification |o | |only iOS | |message |string |message for notification |o | | | +|subtitle |string |subtitle for notification |o | |only iOS | |badge |int |badge count |- |0 |only iOS | |sound |string |sound type |- | |only iOS | |expiry |int |expiration for notification |- |0 |only iOS. | From 04ab774241a5ada889b956dd7534240ad796ef19 Mon Sep 17 00:00:00 2001 From: timakin Date: Tue, 4 Jul 2017 09:13:27 +0900 Subject: [PATCH 4/5] changed spec to untag the required flags --- SPEC.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SPEC.md b/SPEC.md index 357c316..bcb925e 100644 --- a/SPEC.md +++ b/SPEC.md @@ -27,6 +27,8 @@ The JSON below is the request-body example. "token" : ["xxx"], "platform" : 1, "message" : "Hello, iOS!", + "title": "Greeting", + "subtitle": "greeting", "badge" : 1, "sound" : "default", "content_available" : false, @@ -37,9 +39,7 @@ The JSON below is the request-body example. { "token" : ["yyy"], "platform" : 2, - "title": "Greeting", "message" : "Hello, Android!", - "subtitle": "greeting", "collapse_key" : "update", "delay_while_idle" : true, "time_to_live" : 10 @@ -54,9 +54,9 @@ The request-body must has the `notifications` array. There is the parameter tabl |-----------------|------------|-----------------------------------------|--------|-------|----------------| |token |string array|device tokens |o | | | |platform |int |platform(iOS,Android) |o | |1=iOS, 2=Android| -|title |string |title for notification |o | |only iOS | |message |string |message for notification |o | | | -|subtitle |string |subtitle for notification |o | |only iOS | +|title |string |title for notification |- | |only iOS | +|subtitle |string |subtitle for notification |- | |only iOS | |badge |int |badge count |- |0 |only iOS | |sound |string |sound type |- | |only iOS | |expiry |int |expiration for notification |- |0 |only iOS. | From b33e01489f83437337353aa35097a2301f9c7e29 Mon Sep 17 00:00:00 2001 From: timakin Date: Tue, 4 Jul 2017 09:17:11 +0900 Subject: [PATCH 5/5] parameter priority --- samples/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client.go b/samples/client.go index caddce7..e90fc64 100644 --- a/samples/client.go +++ b/samples/client.go @@ -59,8 +59,8 @@ func main() { if *iOSToken != "" { req.Notifications[i].Tokens = append(req.Notifications[i].Tokens, *iOSToken) req.Notifications[i].Platform = 1 - req.Notifications[i].Title = "Greeting" req.Notifications[i].Message = "Hello, iOS!" + req.Notifications[i].Title = "Greeting" req.Notifications[i].Subtitle = "greeting" req.Notifications[i].Badge = 1 req.Notifications[i].Sound = "default"