Add custom field with account list

This commit is contained in:
Andre Medeiros 2021-07-27 15:25:22 -04:00
parent 233e66e9a7
commit ebd5fce678

View file

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"strings"
"github.com/dustin/go-humanize/english" "github.com/dustin/go-humanize/english"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
@ -67,13 +68,14 @@ func (a *api) testDeviceHandler(w http.ResponseWriter, r *http.Request, ps httpr
users = append(users, user) users = append(users, user)
} }
body := fmt.Sprintf("Active usernames are: %s", english.OxfordWordSeries(users, "and")) body := fmt.Sprintf("Active usernames are: %s. Tap me for more info!", english.OxfordWordSeries(users, "and"))
notification := &apns2.Notification{} notification := &apns2.Notification{}
notification.Topic = "com.christianselig.Apollo" notification.Topic = "com.christianselig.Apollo"
notification.DeviceToken = d.APNSToken notification.DeviceToken = d.APNSToken
notification.Payload = payload. notification.Payload = payload.
NewPayload(). NewPayload().
Category("test-notification"). Category("test-notification").
Custom("test_accounts", strings.Join(users, ",")).
AlertTitle(notificationTitle). AlertTitle(notificationTitle).
AlertBody(body) AlertBody(body)