客户端应用程序未通过node.js

时间:2018-03-21 04:43:05

标签: android node.js firebase firebase-admin

我正在开发一个应用程序,我必须在fcm-node / firebase-admin的帮助下从节点服务器向Android设备发送通知。服务器成功发送通知但客户端应用程序无法接收通知。代码如下:

var FCM = require('fcm-node')

var serverKey = require('./myapplication3-efc5b-firebase-adminsdk-haq21-361858e343.json') //put the generated private key path here    

var fcm = new FCM(serverKey)

var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
    to: 'e4rIFxa5bUo:APA91bH_eDZjZW1Fh5Ib6gI26fbS66bP7qBvRoe740FQNNox8QgUADt_nEF-7Bxze_lB5LuMA9JJcrbaGzd_VLIWaQPUwF4qWrpsixOTZAxK3YZNydLuZLXDw1SpBiYCAkYhajhUGC2l', 
   // collapse_key: 'notification',

    notification: {
        title: 'Title', 
        body: 'Trial' 
    },

    data: {  //you can send only notification or only data(or include both)
        my_key: 'my value',
        my_another_key: 'my another value'
    }
}


fcm.send(message, function(err, response){
    if (err) {
        console.log(err)
    } else {
        console.log("Successfully sent with response: ", response)
    }
})

Output of node server

0 个答案:

没有答案