Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Web.WebPush
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
Constructors
Subscription | |
Fields
|
Instances
Show Subscription Source # | |
Defined in Web.WebPush | |
Eq Subscription Source # | |
Defined in Web.WebPush Methods (==) :: Subscription -> Subscription -> Bool Source # (/=) :: Subscription -> Subscription -> Bool Source # | |
Ord Subscription Source # | |
Defined in Web.WebPush Methods 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
Constructors
VapidConfig | |
Fields
|
data PushNotification msg Source #
Web push notification expiration and message to send
Constructors
PushNotification | |
Fields
|
Instances
Show msg => Show (PushNotification msg) Source # | |
Defined in Web.WebPush | |
Eq msg => Eq (PushNotification msg) Source # | |
Defined in Web.WebPush Methods (==) :: PushNotification msg -> PushNotification msg -> Bool Source # (/=) :: PushNotification msg -> PushNotification msg -> Bool Source # | |
Ord msg => Ord (PushNotification msg) Source # | |
Defined in Web.WebPush Methods 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
Constructors
PushNotificationCreated | |
Fields
|
Instances
Show PushNotificationCreated Source # | |
Defined in Web.WebPush | |
Eq PushNotificationCreated Source # | |
Defined in Web.WebPush Methods (==) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # (/=) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # | |
Ord PushNotificationCreated Source # | |
Defined in Web.WebPush Methods compare :: PushNotificationCreated -> PushNotificationCreated -> Ordering Source # (<) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # (<=) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # (>) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # (>=) :: PushNotificationCreated -> PushNotificationCreated -> Bool Source # max :: PushNotificationCreated -> PushNotificationCreated -> PushNotificationCreated Source # min :: PushNotificationCreated -> PushNotificationCreated -> PushNotificationCreated Source # |
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 |
Instances
Exception PushNotificationError Source # | |
Defined in Web.WebPush | |
Show PushNotificationError Source # | |
Defined in Web.WebPush |
type PushP256dh = Text Source #
module Web.WebPush.Keys