44

I'm implementing Push Notification for Web App via Firebase and follow this guidelines from Google

https://github.com/firebase/quickstart-js/tree/master/messaging

On index.html I see this code

    // [START get_messaging_object]
    // Retrieve Firebase Messaging object.
    const messaging = firebase.messaging();
    // [END get_messaging_object]

    // [START set_public_vapid_key]
    // Add the public key generated from the console here.
    messaging.usePublicVapidKey('<YOUR_PUBLIC_VAPID_KEY_HERE>');
    // [END set_public_vapid_key]

My question is "What is Vapid Key ? and Where I can find this key ?"

Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43

1 Answers1

123

Based on https://firebase.google.com/docs/cloud-messaging/js/client

Vapid Key is "Voluntary Application Server Identification". We can find it in:

  1. Open the Cloud Messaging tab of the Firebase console Settings pane and scroll to the Web configuration section.
  2. In the Web Push certificates tab, click Generate Key Pair. The console displays a notice that the key pair was generated, and displays the public key string and date added.

Or look at steps by steps images below

  1. Open Project settings

enter image description here

  1. Choose Cloud Messaging, scroll down to Web configuration. In Web Push certificates you can find Vapid key ( If it doesn't exists, click Generate Key Pair to create )

enter image description here

enter image description here

Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43