Skip to content

Commit

Permalink
Handle test notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
larkox committed Feb 23, 2022
1 parent f181455 commit 36bd327
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion server/android_notification_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus
data := map[string]interface{}{
"ack_id": msg.AckID,
"type": pushType,
"badge": msg.Badge,
"version": msg.Version,
"channel_id": msg.ChannelID,
"is_crt_enabled": msg.IsCRTEnabled,
}

if msg.Badge != -1 {
data["badge"] = msg.Badge
}

if msg.RootID != "" {
data["root_id"] = msg.RootID
}
Expand Down
6 changes: 4 additions & 2 deletions server/apple_notification_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func (me *AppleNotificationServer) Initialize() bool {
func (me *AppleNotificationServer) SendNotification(msg *PushNotification) PushResponse {

data := payload.NewPayload()
data.Badge(msg.Badge)
if msg.Badge != -1 {
data.Badge(msg.Badge)
}

notification := &apns.Notification{}
notification.DeviceToken = msg.DeviceID
Expand Down Expand Up @@ -114,7 +116,7 @@ func (me *AppleNotificationServer) SendNotification(msg *PushNotification) PushR
data.Custom("channel_name", msg.ChannelName)
}
}
case PushTypeClear:
case PushTypeClear, PushTypeTest:
data.ContentAvailable()
case PushTypeUpdateBadge:
// Handled by the apps, nothing else to do here
Expand Down
1 change: 1 addition & 0 deletions server/push_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
PushTypeClear = "clear"
PushTypeUpdateBadge = "update_badge"
PushTypeSession = "session"
PushTypeTest = "test"

PushMessageV2 = "v2"

Expand Down

0 comments on commit 36bd327

Please sign in to comment.