web-push-0.5: Send messages using Web Push protocol.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Web.WebPush

Synopsis

Functions

sendPushNotification :: (MonadIO m, ToJSON msg, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> Subscription -> m (Either PushNotificationError PushNotificationCreated) Source #

Send a Push Message. Read the message in Service Worker notification handler in browser:

self.addEventListener('push', function(event){ console.log(event.data.json()); });

sendPushNotifications :: (MonadIO m, ToJSON msg, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> [Subscription] -> m [(Subscription, Either PushNotificationError PushNotificationCreated)] Source #

Send a push notification to multiple subscribers similar to sendPushNotification but shares VAPID keys across multiple requests

Types

data Subscription Source #

Subscription information for a push notification

Constructors

Subscription 

Fields

data VapidConfig Source #

Configuration for VAPID server identification

Constructors

VapidConfig 

Fields

data PushNotification msg Source #

Web push notification expiration and message to send

Constructors

PushNotification 

Fields

data PushNotificationError Source #

RecepientEndpointNotFound comes up when the endpoint is no longer recognized by the push service. This may happen if the user has cancelled the push subscription, and hence deleted the endpoint. You may want to delete the endpoint from database in this case, or if EndpointParseFailed.

Constructors

EndpointParseFailed HttpException

Endpoint URL could not be parsed

PushNotificationBadHost URI 
PushEncryptError EncryptError 
ApplicationKeyEncodeError String

Application server key encoding failed

RecepientEndpointNotFound

The endpoint is no longer recognized by the push service

PushRequestFailed SomeException

Push request failed

PushRequestNotCreated (Response ByteString)

Push request failed with non-201 status code