移动设备未收到FCM通知

时间:2019-02-28 08:52:00

标签: node.js push-notification

我制作了node js应用程序,该应用程序将通知发送到设备。我使用了请求npm软件包,并使用了https://fcm.googleapis.com/fcm/send作为通知。

通过此操作,我获得了日志成功:1,但未在设备中收到通知。 下面是我的代码:

function sendMessageToUser(deviceId, message) {
    request({
        url: 'https://fcm.googleapis.com/fcm/send',
        method: 'POST',
        headers: {
        'Content-Type' :' application/json',
        'Authorization': 'key=AAAA..'
        },
        body: JSON.stringify(
        { 
            to : deviceId,
            priority: 'high',
            notification: message
        }
        )
    }, (error, respoonse, body) => {
        console.log('output... ', body, '\n',respoonse.statusCode);
        if(error) {
            console.log('error... ', error);
        }
        else {
            console.log('no error ');
        }
    });
}
    
    sendMessageToUser(
    "dOGj..",
    { notification: {
            body:'this is the body',
            title: 'this is the title'
        }
    }
    );

授权密钥和设备令牌正确。请帮我弄错我的地方!

0 个答案:

没有答案
相关问题