Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- sendPushNotification :: (MonadIO m, ToJSON msg, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> Subscription -> m (Either PushNotificationError PushNotificationCreated)
- sendPushNotifications :: (MonadIO m, ToJSON msg, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> [Subscription] -> m [(Subscription, Either PushNotificationError PushNotificationCreated)]
- data Subscription = Subscription {}
- data VapidConfig = VapidConfig {}
- data PushNotification msg = PushNotification {
- pnExpireInSeconds :: Int
- pnMessage :: msg
- data PushNotificationCreated = PushNotificationCreated {}
- data PushNotificationError
- type PushP256dh = Text
- type PushAuth = Text
- module Web.WebPush.Keys
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
Subscription | |
|
Instances
Show Subscription Source # | |
Defined in Web.WebPush | |
Eq Subscription Source # | |
Defined in Web.WebPush (==) :: Subscription -> Subscription -> Bool Source # (/=) :: Subscription -> Subscription -> Bool Source # | |
Ord Subscription Source # | |
Defined in Web.WebPush compare :: Subscription -> Subscription -> Ordering Source # (<) :: Subscription -> Subscription -> Bool Source # (<=) :: Subscription -> Subscription -> Bool Source # (>) :: Subscription -> Subscription -> Bool Source # (>=) :: Subscription -> Subscription -> Bool Source # max :: Subscription -> Subscription -> Subscription Source # min :: Subscription -> Subscription -> Subscription Source # |
data VapidConfig Source #
Configuration for VAPID server identification
VapidConfig | |
|
data PushNotification msg Source #
Web push notification expiration and message to send
PushNotification | |
|
Instances
Show msg => Show (PushNotification msg) Source # | |
Defined in Web.WebPush | |
Eq msg => Eq (PushNotification msg) Source # | |
Defined in Web.WebPush (==) :: PushNotification msg -> PushNotification msg -> Bool Source # (/=) :: PushNotification msg -> PushNotification msg -> Bool Source # | |
Ord msg => Ord (PushNotification msg) Source # | |
Defined in Web.WebPush compare :: PushNotification msg -> PushNotification msg -> Ordering Source # (<) :: PushNotification msg -> PushNotification msg -> Bool Source # (<=) :: PushNotification msg -> PushNotification msg -> Bool Source # (>) :: PushNotification msg -> PushNotification msg -> Bool Source # (>=) :: PushNotification msg -> PushNotification msg -> Bool Source # max :: PushNotification msg -> PushNotification msg -> PushNotification msg Source # min :: PushNotification msg -> PushNotification msg -> PushNotification msg Source # |
data PushNotificationCreated Source #
Result of a successful push notification request
PushNotificationCreated | |
|
Instances
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
.
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 |
Instances
Exception PushNotificationError Source # | |
Defined in Web.WebPush | |
Show PushNotificationError Source # | |
Defined in Web.WebPush |
type PushP256dh = Text Source #
module Web.WebPush.Keys