Firebase Cloud Messaging无法以iOS格式的正确格式发送aps负载通知内容&服务扩展 [英] Firebase Cloud Messaging not sending aps payload in correct format for iOS Notification Content & Service Extensions
问题描述
现在我已经将内容扩展和服务扩展添加到应用程序。内容扩展在我使用本地通知时起作用,但就可选字段而言,Firebase消息负载似乎不正确。这是一个链接到我的控制台的图像:
这里是Firebase远程通知有效内容(有些长数字的Google编辑是匿名的:
{
aps =
{
alert =
{
body =Eureka!11;
title =病人做得不好;
};
};
category = provider-body-panel;
gcm.message_id = 0:149073;
gcm.ne = 1;
google.cac_id = 2825604;
google.cae = 1;
google.cats = 149073;
google.caudt = 0;
mutable-content = 1;
}
看来类别和可变内容不在正确的位置,它们应该在aps有效载荷中。
我怎样才能得到这些选项在有效载荷,以便我的应用程序可以正确解析它,并将其与内容和服务扩展连接?
我将要提到FCM有两种类型的消息有效载荷。 通知
和数据
。请参阅文档。
通过Firebase通知控制台发送通知时,它将被视为通知
有效内容。但是,如果您添加自定义数据,则会将其作为自定义键值对添加到有效内容中。
{
notification:{
body:Eureka!,
title:病人做得不好
,
$ bdata:{
category :provider-body-panel,
mutable-content:true,
click_action:provider-body-panel
}
}
有什么不对? 请参阅文档以了解 here 。 它是目前无法在使用Firebase通知控制台时设置 然后从您自己的应用程序服务器发送它。你也可以通过使用邮递员或 cURL p> I'm trying to implement notifications using Firebase. The notification is received correctly when the app is in the background or foreground. So, the basic mechanics are working. Now I've added Content Extensions and Service Extensions to the app. The Content Extension works when I use a local notification, but the Firebase message payload seems incorrect as far as the optional fields are considered. Here is a link to an image of my console: And here is the Firebase remote notification payload that comes across (with some of the long Google numbers edited for anonymity: It appears that the "category" and "mutable-content" are not in the correct place. They should be in the aps payload. How can I get those options to be in the payload so that my app can correctly parse it and connect it with the Content and Service Extensions? To start off, I'm going to mention that there are two types of message payloads for FCM. When sending notifications through the Firebase Notifications Console, it will be treated as a For example, in your post, the FCM payload should look something like this: What's wrong? See the docs for the parameters here. It it is currently not possible to set the value for Then send it from your own App Server. You could also do this by using Postman or cURL 这篇关于Firebase Cloud Messaging无法以iOS格式的正确格式发送aps负载通知内容&服务扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
click_action
应位于通知
中。
mutable-content
应该是 mutable_content
(注意下划线)并且应该在 >作为通知
。
click_acti
click_action
和 mutable_content
的值。您必须自己构建有效内容,如下所示:
{
to:< REGISTRATION_TOKEN_HERE>,
mutable-content:true,
notification:{
body:Eureka!,
title:Patient is not做得好,
click_action:provider-body-panel
}
}
{
aps =
{
alert =
{
body = "Eureka! 11";
title = "Patient is not doing well";
};
};
category = provider-body-panel;
gcm.message_id = 0:149073;
gcm.n.e = 1;
google.c.a.c_id = 2825604;
google.c.a.e = 1;
google.c.a.ts = 149073;
google.c.a.udt = 0;
mutable-content = 1;
}
notification
and data
. See the documentation herenotification
payload. However, if you add in Custom Data, it will add it in the payload as a custom key-value pair.{
"notification": {
"body" : "Eureka!",
"title": "Patient is not doing well"
},
"data": {
"category": "provider-body-panel",
"mutable-content" : true,
"click_action" : "provider-body-panel"
}
}
click_action
should be inside notification
.mutable-content
should be mutable_content
(notice the underscore) and should be on the same level as notification
.category
parameter for FCM, click_action
already corresponds to it.click_action
and mutable_content
when using the Firebase Notifications Console. You'll have to build the payload yourself, something like this:{
"to": "<REGISTRATION_TOKEN_HERE>",
"mutable-content" : true,
"notification": {
"body" : "Eureka!",
"title": "Patient is not doing well",
"click_action" : "provider-body-panel"
}
}