Home > Software engineering >  Firebase Admin SDK. Send a notification to a specific platform
Firebase Admin SDK. Send a notification to a specific platform

Time:11-22

I have implemented a C# function that sends push notifications to mobile devices using firebase, and it's SDK for .Net.

This was smoothly working on IOS devices, but today an Android developer came and told me that the current push structure is not working for them due to some Android limitations.

My original payload is:

{
 Notification: {
  Title: "Title",
  Body: "Body",
 },
 Data: {
 "Key1": "Value1"
 }
}

The problem here, is that Android can not load the push if it contains "Notification", when the app is in Background. Explanation.

What I have come with as a solution in my mind is, I could simply send two different pushes, one with the Notification content for IOS, and another just with all in the data dictionary for Android.

All looks good until here, but the issue is that I can not find the way on the SDK documentation or classes that allows me to send a push 'just for Android devices' or just for another platform.

I know this is possible to do on the firebase console though, so I expect it to be possible on the SDK.

CodePudding user response:

There is no API to send a message to all Android devices. The common solution for this is to subscribe all Android devices to a specific topic, and then send the message to that topic.

  • Related