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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With