Flutter firebase云功能,有效载荷问题

问题描述 投票:0回答:1

我正在使用firebase云功能发送推送通知。它有效,但默认情况下会显示徽章,并在通知到来时不播放声音。

下面是我的playload代码。

        var playload = {
            notification: {
                title: msgData.title,
                body: msgData.message,
                sound: 'default',
                badge: '0',
                click_action: 'FLUTTER_NOTIFICATION_CLICK'
            }, 
            data: {
                title: msgData.title,
                body: msgData.message,
                sound: 'default',
                badge: '0',
                click_action: 'FLUTTER_NOTIFICATION_CLICK'
            }               
        }
        var options = {
            priority: "high",
            timeToLive: 60 * 60 * 24
          };
        return admin.messaging().sendToDevice(tokens, playload, options).then((response) => {
            console.log('Sent to all the devices');
            return response;
        }).catch((err) => {
            console.log(err);
            return 0;
        })

我设置了'声音':'默认'和徽章:'0'但是没有帮助我。

更新:

我已尝试使用双引号键和值,但尚未使用。

        var playload = {
            "notification": {
                "title": msgData.title,
                "body": msgData.message,
                "sound": "default",
                "badge": "0",
                "click_action": "FLUTTER_NOTIFICATION_CLICK"
            },
            "data": {
                "title": msgData.title,
                "body": msgData.message,
                "sound": "default",
                "badge": "0",
                "click_action": "FLUTTER_NOTIFICATION_CLICK"
            }
        }
android dart flutter firebase-cloud-messaging
1个回答
0
投票

您是否尝试用双引号替换单引号?

来自JSON.org

值可以是双引号中的字符串,也可以是数字,或者true或false或null,或者是对象或数组。这些结构可以嵌套。

邮件的标题和正文在最终失败之前会被处理,这可能就是为什么您的格式似乎没问题。

让我知道这是否对您有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.