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

274
Visualizações
messaging.requestPermission is not a function

trying to send push notification to app but i need permission from user for that but getting this error that messaging.requestPermission is not a function , here is my code for push notification.js file

import * as  firebase from 'firebase/app';
import { getMessaging } from "firebase/messaging";
export const  initializeFirebase = () => {
  firebase.initializeApp({
    apiKey: "",
    authDomain: "",
    projectId: "pushnotification-9b180",
    storageBucket: "pushnotification-9b180.appspot.com",
    messagingSenderId: "878043563283",
    appId: "1:878043563283:web:c2a44f3c8b02ad8a17c6e6",
    measurementId: "G-GMWQKL94ZD"
  });
}
 
export const askForPermissionToReceiveNotifications = async () => {
    try {
      const messaging = getMessaging();

      await messaging.requestPermission();
      const token = await messaging.getToken();
      console.log('Your token is:', token);
      
      return token;
    } catch (error) {
      console.error(error);
    }
  }

Here is the screenshot of errorserros

about 4 years ago · Juan Pablo Isaza
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