Skip to content

Commit 7602f41

Browse files
committed
docs: improve readme with additional pointers to push api
1 parent 12c9433 commit 7602f41

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Web push notifications channel for Laravel
1+
# Web Push Notifications Channel for Laravel
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/webpush.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/webpush)
44
![Build Status](https://github.com/laravel-notification-channels/webpush/workflows/tests/badge.svg)
@@ -10,15 +10,15 @@ This package makes it easy to send web push notifications with Laravel.
1010

1111
## Installation
1212

13-
You can install the package via composer:
13+
You can install the package via Composer:
1414

15-
``` bash
15+
```bash
1616
composer require laravel-notification-channels/webpush
1717
```
1818

19-
First add the `NotificationChannels\WebPush\HasPushSubscriptions` trait to your `User` model:
19+
First, add the `NotificationChannels\WebPush\HasPushSubscriptions` trait to your `User` model:
2020

21-
``` php
21+
```php
2222
use NotificationChannels\WebPush\HasPushSubscriptions;
2323

2424
class User extends Model
@@ -27,43 +27,41 @@ class User extends Model
2727
}
2828
```
2929

30-
Next publish the migration with:
30+
Next, publish the migration with:
3131

32-
``` bash
32+
```bash
3333
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"
3434
```
3535

3636
Run the migrate command to create the necessary table:
3737

38-
``` bash
38+
```bash
3939
php artisan migrate
4040
```
4141

4242
You can also publish the config file with:
4343

44-
``` bash
44+
```bash
4545
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="config"
4646
```
4747

4848
Generate the VAPID keys (required for browser authentication) with:
4949

50-
``` bash
50+
```bash
5151
php artisan webpush:vapid
5252
```
5353

54-
This command will set `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY`in your `.env` file.
54+
This command will set `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY` in your `.env` file. You need the `VAPID_PUBLIC_KEY` as `applicationServerKey` when using the [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API).
5555

56-
> Note: if targeting Safari or iOS after 2023, you will need to include the `VAPID_SUBJECT` variable as well or Apple will return a `BadJwtToken` error.
56+
> **Note:** If targeting Safari or iOS after 2023, you will need to include the `VAPID_SUBJECT` variable as well, or Apple will return a `BadJwtToken` error.
5757
5858
__These keys must be safely stored and should not change.__
5959

60-
If you still want support for [Google Cloud Messaging](https://console.cloud.google.com), set the `GCM_KEY` and `GCM_SENDER_ID` in your `.env` file.
61-
6260
## Usage
6361

64-
Now you can use the channel in your `via()` method inside the notification as well as send a web push notification:
62+
Now you can use the channel in your `via()` method inside the notification and send a web push notification:
6563

66-
``` php
64+
```php
6765
use Illuminate\Notifications\Notification;
6866
use NotificationChannels\WebPush\WebPushMessage;
6967
use NotificationChannels\WebPush\WebPushChannel;
@@ -100,21 +98,23 @@ You can find the available options [here](https://github.com/web-push-libs/web-p
10098

10199
### Save/Update Subscriptions
102100

103-
To save or update a subscription use the `updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null)` method on your user:
101+
To save or update a subscription, use the `updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null)` method on your user:
104102

105-
``` php
103+
```php
106104
$user = \App\User::find(1);
107105

108106
$user->updatePushSubscription($endpoint, $key, $token, $contentEncoding);
109107
```
110108

111-
The `$key` and `$token` are optional and are used to encrypt your notifications. Only encrypted notifications can have a payload.
109+
The `$key` and `$token` are optional and are used to encrypt your notifications. However, all major browsers require encryption when sending notifications.
110+
111+
When using the [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API), `$key` is the value of the `getKey('p256dh')` method, and `$token` is the value of the `getKey('auth')` method of the `PushSubscription` interface.
112112

113113
### Delete Subscriptions
114114

115-
To delete a subscription use the `deletePushSubscription($endpoint)` method on your user:
115+
To delete a subscription, use the `deletePushSubscription($endpoint)` method on your user:
116116

117-
``` php
117+
```php
118118
$user = \App\User::find(1);
119119

120120
$user->deletePushSubscription($endpoint);
@@ -130,13 +130,13 @@ Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed
130130

131131
## Testing
132132

133-
``` bash
134-
$ composer test
133+
```bash
134+
composer test
135135
```
136136

137137
## Security
138138

139-
If you discover any security related issues, please email themsaid@gmail.com instead of using the issue tracker.
139+
If you discover any security-related issues, please email themsaid@gmail.com instead of using the issue tracker.
140140

141141
## Contributing
142142

0 commit comments

Comments
 (0)