【问题标题】:Where can i find client token ID on Firebase Cloud Messaging?我在哪里可以找到 Firebase Cloud Messaging 上的客户端令牌 ID?
【发布时间】:2019-04-04 20:04:56
【问题描述】:

我尝试使用 Firebase Cloud Messaging 找到简单的客户端-服务器应用程序。

我使用 Nodejs 和 this package,但我不知道如何以及在哪里可以找到客户端令牌?

这里是示例代码:

var fcm = require('fcm-notification');
var FCM = new fcm('path/to/privatekey.json');
var token = 'token here';

var message = {
    data: {    //This is only optional, you can send any data
        score: '850',
        time: '2:45'
    },
    notification:{
        title : 'Title of notification',
        body : 'Body of notification'
    },
    token : token
    };

FCM.send(message, function(err, response) {
if(err){
    console.log('error found', err);
}else {
    console.log('response here', response);
}
})

【问题讨论】:

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


    【解决方案1】:

    通常,此人在网站/应用程序上,并且客户端代码要求获得发送通知的权限。如果获得批准,客户端然后调用 FCM 服务器以获取代表该人的令牌。 然后,客户端代码将该令牌保存到具有此人 ID 的数据库中。 然后在发送消息时,您的服务器端软件会从数据库中读取令牌。

    (我希望这是您问题的答案。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-04
      • 2018-11-06
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      相关资源
      最近更新 更多