适用于 iOS 的 FCM 丰富的推送通知负载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42531730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FCM rich push notification payload for iOS
提问by Mathi Arasan
I am using FCM
for my project. It's have rich push notification for a type. I tried to modified most of possible ways to get push from FCM
. I got obly ordinary push from FCM
, not with image.
我正在FCM
为我的项目使用。它有丰富的推送通知类型。我试图修改大多数可能的方法来从FCM
. 我得到了来自 的普通推动FCM
,而不是图像。
I am also check with APNS same coding using push try. I got what expected design for push notification.
我还使用push try检查与 APNS 相同的编码。我得到了推送通知的预期设计。
Here my APNS
payload
这是我的APNS
有效载荷
{
"aps": {
"alert": "Enter your message",
"badge": 1,
"sound": "default",
"content-available": 1,
"mutable-content": 1
},
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
}
Here FCM
payload
这里FCM
有效载荷
{
"to": "dWB537Nz1GA:APA91bHIjJ5....",
"data":
{
"message": "Offer!",
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
},
"notification":
{
"body": "Enter your message",
"sound": "default",
"content-available": 1,
"mutable-content": 1
}
}
Also I am need category more details about payload in FCM
Am I missing any setting in fire-base console or is that from payload.
我是否缺少 fire-base 控制台中的任何设置,或者是来自有效载荷的设置。
回答by AL.
The mutable-content
and content-available
in your FCM payload is incorrect. It should be formatted as mutable_content
and content_available
. Both are booleanand must also be outside the notification
parameter. Like so:
在mutable-content
和content-available
你的FCM有效载荷不正确。它应该被格式化为mutable_content
and content_available
。两者都是布尔值,也必须在notification
参数之外。像这样:
{
"to": "dWB537Nz1GA:APA91bHIjJ5....",
"content_available": true,
"mutable_content": true,
"data":
{
"message": "Offer!",
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
},
"notification":
{
"body": "Enter your message",
"sound": "default"
}
}
For the counterpart of category
in FCM, you should use click_action
:
对于category
FCM 中的对应项,您应该使用click_action
:
The action associated with a user click on the notification.
Corresponds to categoryin the APNs payload.
与用户点击通知相关的操作。
对应于 APNs 负载中的类别。
回答by Jonny
This worked for me. The accepted answer seems to have some unnecessary information.
这对我有用。接受的答案似乎有一些不必要的信息。
{
"to" : "devicekey OR /topics/sometopic",
"mutable_content": true,
"data": {
"mymediavideo": "https://myserver.com/myvideo.mp4"
},
"notification": {
"title": "my title",
"subtitle": "my subtitle",
"body": "some body"
}
}