-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Decode the vapid private key in URL or Raw base64 encoding * Decode and encode VAPID public key
- Loading branch information
1 parent
7ed4780
commit 358c5ab
Showing
5 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ func main() { | |
json.Unmarshal([]byte("<YOUR_SUBSCRIPTION>"), s) | ||
|
||
// Send Notification | ||
_, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{ | ||
resp, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{ | ||
Subscriber: "[email protected]", | ||
VAPIDPublicKey: "<YOUR_VAPID_PUBLIC_KEY>", | ||
VAPIDPrivateKey: "<YOUR_VAPID_PRIVATE_KEY>", | ||
|
@@ -37,6 +37,7 @@ func main() { | |
if err != nil { | ||
// TODO: Handle error | ||
} | ||
defer resp.Body.Close() | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ func main() { | |
json.Unmarshal([]byte(subscription), s) | ||
|
||
// Send Notification | ||
_, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{ | ||
resp, err := webpush.SendNotification([]byte("Test"), s, &webpush.Options{ | ||
Subscriber: "[email protected]", // Do not include "mailto:" | ||
VAPIDPublicKey: vapidPublicKey, | ||
VAPIDPrivateKey: vapidPrivateKey, | ||
|
@@ -27,4 +27,5 @@ func main() { | |
if err != nil { | ||
// TODO: Handle error | ||
} | ||
defer resp.Body.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters