mirror of
https://github.com/hanzoai/notify.git
synced 2026-10-30 15:04:32 +00:00
42 lines
1003 B
Go
42 lines
1003 B
Go
/*
|
|
Package webpush provides a service for sending messages to viber.
|
|
|
|
Usage:
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/hanzoai/notify"
|
|
"github.com/hanzoai/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
|