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

276
Views
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
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!