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

202
Views
Firebase Cloud Messaging - how to detect if a token is expired?

I am doing this

const firebaseApp = initializeApp(configs.FIREBASE)
  const messaging = getMessaging(firebaseApp)

  getToken(messaging, {
    vapidKey: configs.FIREBASE.vapidKey
  })
    .then((currentToken) => {
      if (currentToken) {
        fcm_token.value = currentToken
      } else {
        // Show permission request UI
        console.log('No registration token available in app. Request permission to generate one.');
        // ...
      }
    }).catch((err) => {
    console.log('An error occurred while retrieving token in app. ', err)
    // ...
  });


  onMessage(messaging, (payload) => {

    const notificationTitle = payload.notification.title
    Notify.create(notificationTitle)

    const notificationOptions = {
      body: payload.notification.body,
      icon: payload.notification.icon,
      click_action: payload.notification.click_action
    }

    if (!('Notification' in window)) {
      return;
    }

    if (Notification.permission === 'granted') {
      const notification = new Notification(notificationTitle, notificationOptions)
      notification.onclick = function (event) {
        event.preventDefault()
        window.open(payload.notification.click_action, '_blank')
        notification.close()
      }
    }
  })

I cannot find info about life of currentToken. How much time does it long?

Also... If/when it expires, how my app can be aware of its die?

about 4 years ago · Santiago Gelvez
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!