Skip to content

Commit

Permalink
Set MutableContent and Alert field on the FCM Aps.
Browse files Browse the repository at this point in the history
Needed for NotificationServiceExtension to work.
Also, enable sound on push notifications in iOS.
  • Loading branch information
aforge committed Nov 17, 2019
1 parent 94f1296 commit 17c694a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions server/push/fcm/push_fcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,26 @@ func sendNotifications(rcpt *push.Receipt, config *configType) {
} else if d.Platform == "ios" {
// iOS uses Badge to show the total unread message count.
badge := rcpt.To[uid].Unread
// Need to duplicate these in APNS.Payload.Aps.Alert so
// iOS may call NotificationServiceExtension (if present).
title := "New message"
body := data["content"]
msg.APNS = &fcm.APNSConfig{
Payload: &fcm.APNSPayload{
Aps: &fcm.Aps{Badge: &badge},
Aps: &fcm.Aps{
Badge: &badge,
MutableContent: true,
Sound: "default",
Alert: &fcm.ApsAlert{
Title: title,
Body: body,
},
},
},
}
msg.Notification = &fcm.Notification{
Title: "New message",
Body: data["content"],
Title: title,
Body: body,
}
}

Expand Down

0 comments on commit 17c694a

Please sign in to comment.