# README
pushbell
pushbell is a Go library for sending web push notifications with support for the VAPID (Voluntary Application Server Identification) specification.
Features
- Full implementation of the encryption and Web Push specification, including VAPID.
- Support for multiple push services (Firefox, Chrome, etc.).
- Use fasthttp client.
- Simple and intuitive API.
Installation
go get -u github.com/gootsolution/pushbell
Example
package main
import (
"github.com/gootsolution/pushbell"
)
func main() {
applicationServerPrivateKey := "QxfAyO5dMMrSvDT2_xHxW5aktYPWGE_hT42RKlHilpQ"
applicationServerPublicKey := "BIRM67G3W1fva-ephDo220BbiaOOy-SBk2uzHsmlqMXp_OmkKxYW96cOK5EWnKdkLg2i7N4FYfuxIwm7JWThVSY"
opts := pushbell.NewOptions().ApplyKeys(applicationServerPublicKey, applicationServerPrivateKey)
pb, err := pushbell.NewService(opts)
if err != nil {
panic(err)
}
subscriptionEndpoint := "https://fcm.googleapis.com/fcm/send/e2CN0r8ft38:APA91bES3NaBHe_GgsRp_3Ir7f18L38wA5XYRoqZCbjMPEWnkKa07uxheWE5MGZncsPOr0_34zLaFljVqmNqW76KhPSrjdy_pdInnHPEIYAZpdcIYk8oIfo1F_84uKMSqIDXRhngL76S"
subscriptionAuth := "rm_owGF0xliyVXsrZk1LzQ"
subscriptionP256DH := "BKm5pKbGwkTxu7dJuuLyTCBOCuCi1Fs01ukzjUL5SEX1-b-filqeYASY6gy_QpPHGErGqAyQDYAtprNWYdcsM3Y"
message := []byte("{\"title\": \"My first message\"}")
statusCode, err := pb.Send(&pushbell.Push{
Endpoint: subscriptionEndpoint,
Auth: subscriptionAuth,
P256DH: subscriptionP256DH,
Plaintext: message,
})
if err != nil {
panic(err)
}
}
NOTE: You can use this to play around and make tests without your service workers.
Documentation
Detailed API documentation is available on GoDoc.
License
This project is distributed under the MIT License.
Support and Contributing
If you have any questions, issues, or suggestions, please create an issue in this repository. Pull requests with fixes and improvements are also welcome.
# Functions
CheckStatusCode takes an HTTP status code and returns an error if the status code indicates an error condition.
No description provided by the author
NewService creates new service with given application server keys and subject.
# Constants
Device State - Low battery.
Device State - On either power or Wi-Fi.
Device State - On neither power nor Wi-Fi.
Device State - On power and Wi-Fi.
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author