Skip to content

Commit 8de1ee3

Browse files
Apply suggestions from code review
Co-authored-by: Michael Hoffman <[email protected]>
1 parent 1dde946 commit 8de1ee3

File tree

1 file changed

+5
-5
lines changed
  • microsoft-edge/progressive-web-apps-chromium/how-to

1 file changed

+5
-5
lines changed

microsoft-edge/progressive-web-apps-chromium/how-to/push.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To create a PWA that supports push notifications:
2727
<!-- ====================================================================== -->
2828
## Step 1 - Request the user's permission to receive push notifications
2929

30-
Before you can send push notifications to your PWA, you must request permission from the user to receive messages. To request permission, use the [Notification.requestPermission API](https://developer.mozilla.org/docs/Web/API/Notification/requestPermission_static) in your client-side code, when the user clicks a button, for example:
30+
Before you can send push notifications to your PWA, you must request permission from the user to receive messages. To request permission, use the [Notification.requestPermission API](https://developer.mozilla.org/docs/Web/API/Notification/requestPermission_static) in your client-side code, such as when the user clicks a button:
3131

3232
```javascript
3333
button.addEventListener("click", () => {
@@ -55,7 +55,7 @@ To receive push events from your server, subscribe to push notifications by usin
5555

5656
Before a new push subscription is created, Microsoft Edge checks whether the user has granted the PWA permission to receive notifications.
5757

58-
If the user has not granted the PWA permission to receive notifications, the user is prompted by the browser for permission. If the user doesn't grant permission to the browser, the request to `registration.pushManager.subscribe` throws a `DOMException`.
58+
If the user hasn't granted the PWA permission to receive notifications, the user is prompted by the browser for permission. If the user doesn't grant permission to the browser, the request to `registration.pushManager.subscribe` throws a `DOMException`.
5959

6060
The following code snippet shows how to subscribe to push notifications in your PWA:
6161

@@ -99,23 +99,23 @@ function urlBase64ToUint8Array(base64String) {
9999
}
100100
```
101101

102-
The VAPID key mentioned in the previous code snippet is a public key that is used to identify the server that sends the push messages and encrypt the push message payload. See [Step 3 - Send push messages from your server](#step-3---send-push-messages-from-your-server) for more information about VAPID keys.
102+
The VAPID key that's mentioned in the previous code snippet is a public key that's used to identify the server that sends the push messages and encrypt the push message payload. See [Step 3 - Send push messages from your server](#step-3---send-push-messages-from-your-server) for more information about VAPID keys.
103103

104104

105105
<!-- ====================================================================== -->
106106
## Step 3 - Send push messages from your server
107107

108108
Your application needs VAPID (Voluntary Application Server Identification) keys in order to send push messages from your server to your PWA clients. There are several VAPID key generators available online (for example, [Vapidkeys.com](https://vapidkeys.com)).
109109

110-
Once you have a VAPID key, you can send push messages to your PWA clients by using the Web Push Protocol. To learn more about the protocol, see [The Web Push Protocol](https://web.dev/push-notifications-web-push-protocol/).
110+
Once you have a VAPID key, you can send push messages to your PWA clients by using [the Web Push Protocol](https://web.dev/push-notifications-web-push-protocol/).
111111

112112
You can use a library to send push messages from your server, depending on the programming language you use. For example, you can use the [web-push](https://github.com/web-push-libs/web-push) library if your server uses Node.js. Other libraries are available on the [WebPush libraries repo](https://github.com/web-push-libs/).
113113

114114

115115
<!-- ====================================================================== -->
116116
## Step 4 - Display notifications when push messages are received
117117

118-
After a subscription is created in your PWA (as shown in [Step 2 - Subscribe to push notifications](#step-2---subscribe-to-push-notifications)), add a `push` event handler in your service worker to handle push messages sent by your server.
118+
After a subscription is created in your PWA (as shown in [Step 2 - Subscribe to push notifications](#step-2---subscribe-to-push-notifications)), add a `push` event handler in your service worker to handle push messages that are sent by your server.
119119

120120
The following code snippet shows how to display a notification when a push message is received:
121121

0 commit comments

Comments
 (0)