Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
Firebase javascript v9 getMessaging().subscribeToTopic() undefined

I am using firebase javascript api v9 in my react project and i am using the code below as suggested by the oficial documentation



    import { getMessaging } from "firebase/messaging";
    
    // These registration tokens come from the client FCM SDKs.
    const registrationTokens = [
      'fcm_token_string'
    ];
    
    // Subscribe the devices corresponding to the registration tokens to the topic
    getMessaging().subscribeToTopic(registrationTokens, topic)
      .then((response) => {
        // See the MessagingTopicManagementResponse reference documentation [enter link description here][1]for the contents of response.
        console.log('Successfully subscribed to topic:', response);
      })
      .catch((error) => {
        console.log('Error subscribing to topic:', error);
      });


However, despite of doing exactly what the documation of firebase api v9 says, I am getting undefined when accessing getMessaging().subscribeToTopic function.

I am wondering if this function was moved to another component and the documentation has become outdated.

I would appreciate any help. Thank you in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is no way to subscribe a web client to a topic from within the client-side code (see How to subscribe to topics with web browser using Firebase Cloud Messaging). So that code you got from the documentation is supposed to run on the server, using the Firebase Admin SDK for Node.js, which still uses the namespaced ...subscribeToTopic() syntax.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda