【问题标题】:Fcm Notifications push android/IOS nodejsFcm Notifications 推送 android/IOS nodejs
【发布时间】:2017-02-14 11:39:19
【问题描述】:

我正在寻找从 Nodejs 服务器发送通知,但我遇到了一些我不知道如何解决的错误。有人可以帮助我吗?我在 Internet 上找到了这个可能的解决方案 --> URL

这是我在 nodejs 中的代码

var FCM = require('fcm-push');

function sendNotification (){

var serverKey = 'AAAAJnK3Ing:AP-(more caracters)AwAlBL_CvXIkFM2UufYZHYkvhC7FP3Tu16mlI';
var fcm = new FCM(serverKey);

var message = {
  to: 'd2b2v(more caracters token)DUmAXqU-uHptJJLRPXukl', 
  /*data: {
      your_custom_data_key: 'your_custom_data_value'
  },*/
  notification: {
      title: 'notification',
      body: 'This is a notification from node'
  }
};

//callback style
fcm.send(message, function(err, response){
  if (err) {
      console.log("****************************************************")
      console.log(message)
      console.log("Something has gone wrong!");
  } else {
      console.log("Successfully sent with response: ", response);
  }
});

//promise style
fcm.send(message)
  .then(function(response){
      console.log("Successfully sent with response: ", response);
  })
  .catch(function(err){
      console.log("----------------------------------------------------")
      console.log("Something has gone wrong!");
      console.error(err);
  })

}

module.exports = {
  sendNotification
}

I am getting this error

【问题讨论】:

    标签: android ios node.js firebase firebase-cloud-messaging


    【解决方案1】:

    尝试检查您的防火墙是否允许连接 443 端口。它似乎无法创建连接。

    【讨论】:

    • 是的,它是开放和倾​​听的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    相关资源
    最近更新 更多