Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one distinguish between Android and IOS Firebase IDs for Push Notifications?

As per my previously asked question, Firebase onMessageReceived not called when app is in the background , I need to change the payload to a 'data' payload as opposed to a 'notification' payload. (See link here -- What is the difference between Firebase push-notifications and FCM messages?).

The problem is, both the IOS and Android app we have utilize Firebase and the IOS app requires the push notification payload to use the 'notification' structure, while Android requires the 'data' payload structure.

My question is therefore, how do you distinguish between Android and IOS tokens / Ids obtained via the firebase sdk?

If our server saves these Ids and needs to send out a push notification, it needs to specify Android vs IOS in order to change the payload structure. Is the only way to accomplish this identification to have an app-based call to the server which differentiates IOS vs Android? Or is there a more sophisticated way using Firebase that will allow us to poinpoint which device it is?

Thanks all.

like image 215
PGMacDesign Avatar asked Jul 24 '17 17:07

PGMacDesign


People also ask

Can Firebase send push notifications iOS?

Firebase Cloud Messaging (FCM) It's easy to fire push notifications from the server to FCM, and it handles the rest for iOS, Android, and the Web.

What is Firebase push notification in Android?

Firebase Cloud Messaging (FCM) is a set of tools that sends push notifications and small messages of up to 4 KB to different platforms: Android, iOS and web. This topic is useful because you use push notifications in a lot of mobile projects. Firebase is one of the simplest methods to get notifications working.

Do Firebase push notification or one signal in your Android app?

While both Firebase and OneSignal can be used to send mobile push notifications, the two platforms have many key differences. Here's an overview of some of them. Deliver all types of Android notifications with accurate previews.

How does push notification work Firebase?

Creating notifications is very straightforward — you simply use the Firebase Notifications GUI in the console to compose and send notifications to apps that are linked to your project in the console. When your app is in the background on a user's device, notifications are delivered to the system tray.


1 Answers

Information about an app instance is available from the Instance ID Service at this endpoint:

https://iid.googleapis.com/iid/info/IID_TOKEN

On success the call returns HTTP status 200 and a JSON object containing various status for the app instance including the platform:

returns ANDROID, IOS, or CHROME to indicate the device platform to which the token belongs

like image 161
Bob Snyder Avatar answered Sep 18 '22 15:09

Bob Snyder