问题描述
我正在使用Firebase Cloud Messaging,并为我的通知创建cron,而不是使用Firebase控制台.我想知道我是否可以使用与Android相同的json.目前,我的android设备收到我发送的通知,但在iOS中则没有.我想知道是否是因为我在notification
对象中使用的某些参数,例如icon
仅用于android平台,会影响结果吗?
I'm using Firebase Cloud Messaging and create a cron for my notification instead of using the Firebase console. I'm wondering if I can use the same json i used for android. Currently my android device receives the notification I send but in my iOS it doesn't. I'm wondering if its because some of the parameter I used like in notification
object for example icon
is only for android platform, does it effect the result?
我的帖子请求看起来像这样
My post request looks like this
{
"registration_ids" : $ids,
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark"
"icon" : "myicon"
},
"data" : {
"Nick" : "Mario",
"Room" : "PortugalVSDenmark"
}
}
更新
按照建议,我为iOS和Android创建了两个不同的cron,在我的iOS中,我只是删除了json中的icon
参数.但是我仍然没有收到任何通知.
As suggested, I created two different cron for my iOS and Android, in my iOS i just removed the icon
parameter in the json. But still i cannot received any notification.
也在Capabilities Tab -> Push Notifications
下,我也在Background Modes-> Remote notifications
中将其切换为ON
.
Also under Capabilities Tab -> Push Notifications
, i toggle it ON
, also in Background Modes-> Remote notifications
.
推荐答案
您可以对android和ios使用相同的json.Firebase Cloud Messaging将为每个平台使用相关参数
You can use the same json for both android and ios.Firebase Cloud Messaging will use the relevant parameters for each platform
示例:
-
icon
将从针对iOS的邮件中删除,因为该平台不支持更改图标.
icon
will be removed from messages targeting iOS since that platform doesn't support changing the icon.
sound
应该是带有扩展名的文件名(iOS要求扩展名).当定位到android设备时,Firebase会删除该扩展名.
sound
should be a filename with extension (extension required for ios). Firebase will remove the extension when targeting an android device.
关于未传递到iOS的消息,请尝试增加priority
参数.
https://firebase.google.com /docs/cloud-messaging/http-server-ref#downstream-http-messages-json
Regarding the messages not being delivered to iOS try to increase the priority
parameter.
https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json
当ios应用程序处于后台时,Firebase使用APN传递消息,而APN通常会延迟优先级不高的消息.
When the ios app is in background Firebase uses APNs to deliver the message, and APNs often delay messages that don't have high priority.
如果这不起作用,请检查您的APNs证书配置.
If that doesn't work please check your APNs certificate configuration.
这篇关于无法在iOS中接收通知[Firebase]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!