使用节点js的FCM推送通知获取无效注册

时间:2019-12-12 07:18:39

标签: android node.js firebase push-notification firebase-cloud-messaging

我正在使用Node js开发REST API,并且有一个休息端点来发送Firebase推送通知。在向Android发送推送通知时遇到了问题

我的错误代码是:

{"multicast_id":6890655614582327866,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

我的代码如下:

var FCM = require('fcm-node');
    var serverKey = 'AAAAXOrkfxk:....cii'; 
    var fcm = new FCM(serverKey);
    var message = { 
        to: '55fc64...21d',     
        notification: {
            title: 'Title of push notification', 
            body: 'Body of push notification' 
        },
        data: {  
            my_key: 'my value',
            my_another_key: 'my another value'
        }
    };
    fcm.send(message, function(err, response){
        if (err) {
            console.log("Something has gone wrong!");
        } else {
            console.log("Successfully sent with response: ", response);
        }
    });

从android获取令牌ID并用邮递员运行它,但始终会出现诸如无效注册之类的错误。 请帮助任何人。

0 个答案:

没有答案