如何区分推送通知的Android和IOS Firebase ID? [英] How does one distinguish between Android and IOS Firebase IDs for Push Notifications?

查看:383
本文介绍了如何区分推送通知的Android和IOS Firebase ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照我以前提出的问题,​​ Firebase onMessageReceived当应用程序在后台不被调用时,我需要将有效载荷更改为数据有效载荷,而不是通知有效载荷。 (请参阅链接 - 有什么区别Firebase推送通知和FCM消息之间?)。
$ b $问题是,IOS和Android应用程序都使用Firebase,IOS应用程序需要推送通知有效载荷才能使用通知结构,而Android需要'数据'有效载荷结构。

我的问题是,您如何区分通过firebase SDK获取的Android和IOS令牌/ ID?



如果我们的服务器保存了这些ID并需要发送推送通知,那么它需要指定Android vs IOS来更改有效负载结构。是唯一的方法来完成这个标识有一个基于应用程序的服务器的区别iOS和Android的呼叫?还是有更复杂的方式使用Firebase,可以让我们指出哪个设备是?



感谢所有人。

解决方案

来自此端点的实例ID服务

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

成功时,调用返回HTTP状态200和包含应用程序实例的各种状态,包括平台


返回ANDROID,IOS或CHROME,表示设备平台为令牌所属的


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.

解决方案

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

这篇关于如何区分推送通知的Android和IOS Firebase ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆