forked from nikoksr/notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
41 lines (30 loc) · 1003 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Package webpush provides a service for sending messages to viber.
Usage:
package main
import (
"context"
"log"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/webpush"
)
const vapidPublicKey = "..." // Add a vapidPublicKey
const vapidPrivateKey = "..." // Add a vapidPrivateKey
func main() {
subscription := webpush.Subscription{
Endpoint: "https://your-endpoint",
Keys: {
Auth: "...",
P256dh: "...",
},
}
webpushSvc := webpush.New(vapidPublicKey, vapidPrivateKey)
webpushSvc.AddReceivers(subscription)
notifier := notify.NewWithServices(webpushSvc)
if err := notifier.Send(context.Background(), "TEST", "Message using golang notifier library"); err != nil {
log.Fatalf("notifier.Send() failed: %s", err.Error())
}
log.Println("Notification sent successfully")
}
*/
package webpush