Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Unable to subscribe to topic in web using nodejs

I need to subscribe to topic in login function, I get the device token and push it into array named tokens

And I use fcm function to subscribe, First : import fcm and intialize a new fcm with my server_key :

var FCM = require("fcm-node");
let fcm = new FCM(process.env.SERVER_KEY);

Then use this function to subscribe to topic

const tokens = [];

// deviceToken it contain my device Token
tokens.push(deviceToken);

fcm.subscribeToTopic({ deviceToken: tokens }, { topicName: "general" })
   .then((resposne) => {console.log(resposne)})
   .catch((error) => {console.log(error)})

It return in terminal:

 CB(err, res);
                ^

TypeError: CB is not a function

and i try to change the function to :

fcm.subscribeToTopic(deviceToken, "cars", (err, response) => {
    if (err) {
      console.log("subscribeToTopicError:", err);
    } else {
      console.log("subscribeToTopicResponse:", response);
    }
  });

it return { statusCode: 400, message: 'Bad Request' }

How can i subscribe to topic with nodejs ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If someone meet this problem in the future the problem because the "fcm-node" It has no support since about 2017!

You can use "firebase-admin" Instead of that, Then you will not meet such this problem.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!