APN - 使用FCM发送后台更新通知时出错

时间:2018-03-14 22:48:26

标签: firebase apple-push-notifications firebase-cloud-messaging google-cloud-functions firebase-admin

我正在尝试使用FCM和管理员功能发送无声通知 那是我的功能:

exports.testNotification = functions.https.onRequest((req, res) => {

   let token = req.query.token;

    let message = {
        data: {
            data1: 'extra1',
            data2: 'extra2'
        },
        apns: {
            headers: {
                'apns-priority': '10',
                'apns-expiration': '0'
            },
            payload: {
                aps: {
                    'content-available': 1
                },
                'acme1' : 'bar'
            }
        },
        token: token
    };

    admin.messaging().send(message).then((response) => {
        res.status(200).send('OK');
    }).catch((error) => {
        res.status(200).send(error); --DISPLAY ERROR HERE
    });
});

我收到了这个错误

{"code":"messaging/invalid-argument","message":"Request contains an invalid argument."}

如果我将徽章或声音设置为“aps”字典,则可以正常工作:

aps: {
    'content-available': 1,
    badge:4
},

Apple developer guide中,清单7-1与我的测试相同,即没有徽章或声音。

我不需要声音或徽章,我必须发送带有“数据”值(extra1,extra2)的通知,检索它们然后能够创建使用它的本地通知。 徽章和声音是为每个最终用户定制的,我无法在通知有效负载中设置它。

0 个答案:

没有答案