Firebase Cloud Messaging where to find PUBLIC VAPI

2019-07-25 05:06发布

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 ?"

1条回答
混吃等死
2楼-- · 2019-07-25 05:38

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

查看更多
登录 后发表回答