Silent Google FCM notification using Alpakka

Hi,
I need to send silent push FCM notification. How can I acheive that using Alpakka?

According to FCM Doc I should add "content_available": true to the request.

However some other sources mention that I need to add "aps": { "content-available": 1 }
In Alpakka I found ApnsConfig class and try this:

val notification = FcmNotification.empty
      .withTarget(Topic("test"))
      .withData(Map(
        "myKey" -> "myValue"
      ))
      .withApnsConfig(ApnsConfig(Map("apns-push-type" -> "background"), """{"aps": {"content-available" : 1}}"""))

Is it correct? This was the only way I was able to come up with but I feel really confused here. Will this work as expected?

I wrote the most of the FCM flow, but honestly I have no idea. The whole doc is a huge mess and most of the time ‘trial and error’ is the only way to “know” if sth is working as expected or not…

Some thoughts:

  • we use the “new” api and not the “legacy” one that you refered as the doc (new docs)
  • digging deeper; we use this converter to reach this part of the docs and it says that if you use the payload you need to add the title and body “again” (BTW your code seems to ok based on the doc)

Thank you, Gergő for your response and links.

At least I have better feeling about this now. We will test it later and I will try to update this thread with my findings.