Admiral Land
Admiral Land

Reputation: 2492

Where can i find client token ID on Firebase Cloud Messaging?

I try to find simple client-server app using Firebase Cloud Messaging.

I use Nodejs and this package, but I don't know how and where I can find the client token?

Here the example code:

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);
}
})

Upvotes: 1

Views: 389

Answers (1)

user11248879
user11248879

Reputation: 81

Usually, the person is on the website / app and the client code asks for permission to send notifications. If granted, the client then calls the FCM server to get a token that represents that person. The client code then saves that token to a database with the person's id. Then when sending the message your server side software reads the token from the database.

(I hope that is the answer to your question.)

Upvotes: 2

Related Questions