codedge-llc / pigeon

iOS and Android push notifications for Elixir
https://hex.pm/packages/pigeon
MIT License
639 stars 143 forks source link

Set apns headers in FCM.Notification.payload #222

Open rlopzc opened 2 years ago

rlopzc commented 2 years ago

Environment

Current behavior

Manually setting APNS apns-collapse-id header does not work.

alias Pigeon.FCM

notification = 
  FCM.Notification.new("token", %{title: "Test"})
  |> Map.update(:payload, %{}, &(Map.put(&1, :apns, %{headers: %{"apns-collapse-id" => "1"}})))

# First notification
FCM.push(notification)

# Second notification
FCM.push(notification)

When testing it with my phone, the same notification arrives twice.

How do I set the apns collapse id to sent through FCM? I'm not sure if that's the way to set the apns headers field in an FCM.Notification struct.

Documentation:

Expected behavior

Setting APNS collapse-id header replaces previous notification with the same apns-collapse-id