我正在我的某个应用中实现Rich Text Notification。我知道我需要以下列格式的有效载荷:
{
"aps": {
"alert": {
"title": "",
"body": “”
},
"badge": 1,
"sound": "default",
"mutable-content": true,
"content-available": true,
"category": "defaultCategory"
},
"image_url": ""
}
虽然当我尝试使用默认APNS进程时,我成功完成了它,但是我在使用FCM实现它时遇到了一个问题,问题是我没有收到密钥:
mutable-content: 1
category: defaultCategory
我对它进行了探索并找到了一个网址FCM rich push notification payload for iOS ,我也尝试了所提到的密钥。
"mutable_content": true,
"click_action": defaultCategory,
但即使使用这些我也没有得到正确的结果。我在最终更改后收到的当前有效负载是:
{
gcm.notification.category: defaultCategory,
image: /r/u/rustyredsmall.jpg,
type_id: XMH677878912-L-Blue,
type: Product,
aps: {
alert = {
body = "new product notification message2018-05-24 00:00:00";
title = "Product Notification";
};
badge = 1;
sound = default;
},
0: {"mutable_content":true},
gcm.message_id: 0:1527142412430945%98b85c5198b85c51
}
有任何建议,我如何获得正确的有效载荷?
答案 0 :(得分:3)
我调试了问题并成功解决了问题,服务器端的密钥放置存在 问题 。我们在服务器端创建了有效负载:
{
"to”: “xyz”,
"mutable_content": true,
"notification":
{
"body": “this is the message body.“,
"title": “tiltle text”,
"sound": "default",
"badge": 1,
"click_action": "defaultCategory"
},
"data":
{
"type": "Category",
"typeId": "74",
"redirect_title": "",
"image_url": "\/d\/r\/dress_16.jpg",
"notification_id": "1"
}
}
FCM格式化此有效负载并按以下格式将其发送到移动端:
{
gcm.message_id: “0:1527233474081223%98b85c5198b85c51”,
aps: {
alert: {
body: "new product notification message2018-05-24 00:00:00";
title: "Product Notification";
};
badge: 1;
category: “defaultCategory”;
mutable-content: 1;
sound: “default”;
},
notification_id: 11,
typeId: “XMH677878912-L-Blue”,
image_url: “/r/u/rustyredsmall.jpg”,
type: “Product”,
redirect_title: “Midi Dress-L-Blue”
}