Skip to content

Commit 9b53552

Browse files
committed
docs: update README
1 parent 3bfe273 commit 9b53552

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Web Push Elixir
22

3+
Simple web push library for Elixir.
4+
35
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/midarrlabs/web-push-elixir/test.yml)
46
[![codecov](https://codecov.io/gh/midarrlabs/web-push-elixir/graph/badge.svg?token=Y9FG6IFTIN)](https://codecov.io/gh/midarrlabs/web-push-elixir)
57

6-
Simple web push for Elixir
7-
88
## Installation
99

10-
1. The package can be installed by adding `web_push_elixir` to your list of dependencies in `mix.exs`:
10+
1. Add `web_push_elixir` to your list of dependencies in `mix.exs`:
1111

1212
```elixir
1313
def deps do
@@ -17,7 +17,7 @@ def deps do
1717
end
1818
```
1919

20-
2. Run the mix command to generate your Vapid public and private keys:
20+
2. Run mix command to generate your Vapid public and private keys:
2121

2222
```commandline
2323
mix generate.vapid.keys
@@ -32,6 +32,23 @@ environment:
3232
- VAPID_SUBJECT=mailto:[email protected]
3333
```
3434
35+
## Usage
36+
37+
`WebPushElixir` provides a simple public API `send_notification/2` that accepts 2 arguments:
38+
39+
* `subscription`: is the subscription information received from the client.
40+
* `message`: your message string.
41+
42+
```elixir
43+
subscription = '{"endpoint":"http://localhost:4040/some-push-service","keys":{"p256dh":"BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM=","auth":"tBHItJI5svbpez7KI4CCXg=="}}'
44+
message = "Some message"
45+
46+
WebPushElixir.send_notification(subscription, message)
47+
```
48+
49+
For more information on how to subscribe a client, permission UX and more - have a look at [https://web.dev/notifications/](https://web.dev/notifications/)
50+
51+
3552
## Credits
3653

3754
Heavily inspired by [elixir-web-push-encryption](https://github.com/danhper/elixir-web-push-encryption)

0 commit comments

Comments
 (0)