Let's discuss what we just wrote in the preceding code:
- We're using the Firebase messaging reference that we created earlier and executing the requestPermission() function that returns a promise.
- Next, supposing that you're following along with this recipe, after launching the development server you will get the following authorization request from your page:
Figure 2: Application Notification authorization request
- Moving back to the code, if we allow the notification, the promise resolver will be executed and then we will return the registration_token value from the messaging.getToken().
- Next, we're using the Fetch API ...