Skip to content

Commit b821714

Browse files
committed
docs: add docs
1 parent 5314221 commit b821714

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/web_push_elixir.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
defmodule WebPushElixir do
2+
@moduledoc """
3+
Module to send web push notifications with an encrypted payload.
4+
"""
5+
26
defp url_encode(string) do
37
Base.url_encode64(string, padding: false)
48
end
@@ -91,6 +95,18 @@ defmodule WebPushElixir do
9195
signed_json_web_token
9296
end
9397

98+
@doc """
99+
Sends a web push notification with an encrypted payload.
100+
101+
## Arguments
102+
103+
* `subscription` is the subscription information received from the client. Accepted example: `'{"endpoint":"http://localhost:4040/some-push-service","keys":{"p256dh":"BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM=","auth":"tBHItJI5svbpez7KI4CCXg=="}}'`
104+
* `message` is a string payload.
105+
106+
## Return value
107+
108+
Returns the result of `HTTPoison.post`
109+
"""
94110
def send_notification(subscription, message) do
95111
vapid_public_key = url_decode(System.get_env("VAPID_PUBLIC_KEY"))
96112
vapid_private_key = url_decode(System.get_env("VAPID_PRIVATE_KEY"))

0 commit comments

Comments
 (0)