ntfy/cmd/web_push.go
nimbleghost ff5c854192 Add PWA, service worker and Web Push
- Use new notification request/opt-in flow for push
- Implement unsubscribing
- Implement muting
- Implement emojis in title
- Add iOS specific PWA warning
- Don’t use websockets when web push is enabled
- Fix duplicate notifications
- Implement default web push setting
- Implement changing subscription type
- Implement web push subscription refresh
- Implement web push notification click
2023-06-07 20:38:20 +02:00

40 lines
795 B
Go

//go:build !noserver
package cmd
import (
"fmt"
"github.com/SherClockHolmes/webpush-go"
"github.com/urfave/cli/v2"
)
func init() {
commands = append(commands, cmdWebPush)
}
var cmdWebPush = &cli.Command{
Name: "web-push-keys",
Usage: "Generate web push VAPID keys",
UsageText: "ntfy web-push-keys",
Category: categoryServer,
Action: generateWebPushKeys,
}
func generateWebPushKeys(c *cli.Context) error {
privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
if err != nil {
return err
}
fmt.Fprintf(c.App.ErrWriter, `Add the following lines to your config file:
web-push-enabled: true
web-push-public-key: %s
web-push-private-key: %s
web-push-subscriptions-file: <filename>
web-push-email-address: <email address>
`, publicKey, privateKey)
return nil
}