简体   繁体   English

从Firebase向Android和iOS发送推送通知

[英]Send Push Notification from Firebase to Android as well as iOS

I am trying to send push notification to both android and ios. 我正在尝试向android和ios发送推送通知。 On Android push notification is handled by data while on ios notification is required in payload to display the notification. 在Android上,推送通知由数据处理,而在有效负载上需要ios 通知以显示通知。

But if notification part is added and if user is subscribed to the channel on both the device. 但是,如果添加了通知部分,并且用户是否订阅了设备上的频道。 On Android it show 2 messages created by notification part of payload. 在Android上,它显示由有效负载的通知部分创建的2条消息。

Any particular way to send the payload from firebase. 从firebase发送有效负载的任何特定方式。 So that it can run on both the devices. 这样它就可以在两个设备上运行。

Thanks in advance 提前致谢

Like Frank said, Firebase does support sending messages to both iOS and Android. 就像弗兰克所说,Firebase支持向iOS和Android发送消息。

If you send a notification message with a data payload (so both notification and data) the Android client will either display the auto generated notification based on the notification payload if the app is in the background or be passed to the onMessageReceived callback where you have the option to generate a notification based on the data and/or notification payloads if you wish if the app is in the foreground. 如果与数据有效载荷(所以二者通知和数据)的Android客户端将或者显示自动发送通知消息生成的基于通知的通知有效载荷,如果应用程序是在后台传递到您具有的onMessageReceived回调如果您希望应用程序位于前台,则可以选择基于数据和/或通知有效负载生成通知。 There will not be two notifications generated. 不会生成两个通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM