如何使用Firebase Notifications控制台在APNS有效负载中添加mutable_content?

时间:2017-04-05 06:36:00

标签: ios firebase firebase-cloud-messaging firebase-notifications

无法弄清楚如何在aps字典中发送mutable_content = true。这是我从firebase消息控制台发送通知时收到的json有效负载

{
    aps =     {
        alert =         {
            body = "50% off on booking ";
            title = "CompanyName 50% coupon ABC50OFF";
        };
        sound = default;
    };
    "attachment-url" = "https://www.xxxxxxxxx.com/campaign/images_thumb/Toyota-Fortuner-AT.jpg";
    "click_action" = reminder;
    "content_available" = 1;
    "gcm.message_id" = "0:1491225835295720%a84b45aaa84b45aa";
    "gcm.n.e" = 1;
    "gcm.notification.sound2" = default;
    "google.c.a.c_id" = 3829383583613273032;
    "google.c.a.e" = 1;
    "google.c.a.ts" = 1491225835;
    "google.c.a.udt" = 0;
    "mutable_content" = 1;
}

3 个答案:

答案 0 :(得分:2)

使用Firebase Notifications Console时,目前无法设置mutable_content的值。您必须自己构建有效负载,如下所示:

{
    "to": "<REGISTRATION_TOKEN_HERE>",
    "mutable-content" : true,
    "notification": {
        "body" : "Eureka!",
        "title": "Patient is not doing well",
        "click_action" : "provider-body-panel"
    }
}

然后从您自己的App Server发送它。您也可以using PostmancURL

执行此操作

来自我的回答here的修改部分。

答案 1 :(得分:1)

在从Firebase通知控制台发送推送通知时添加Notification image。它将自动在有效负载内添加"mutable-content" : true

enter image description here

答案 2 :(得分:0)

答案不正确,您应该使用“mutable_content”而不是“mutable-content”

{
    "to": "Token",
    "mutable_content" : true,
    "notification" : {
    "body" : "great match!",
    "title": "check"
    }
}