Copyright | (C) 2017 memrange UG |
---|---|
License | BSD3 |
Maintainer | Hans-Christian Esperer <hc@memrange.io> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Send push notifications using Apple's HTTP2 APN API
Synopsis
- newSession :: FilePath -> FilePath -> FilePath -> Bool -> Int -> Int -> ByteString -> IO ApnSession
- newMessage :: JsonApsMessage -> JsonAps
- newMessageWithCustomPayload :: JsonApsMessage -> Text -> JsonAps
- hexEncodedToken :: Text -> ApnToken
- rawToken :: ByteString -> ApnToken
- sendMessage :: ApnSession -> ApnToken -> JsonAps -> IO ApnMessageResult
- sendSilentMessage :: ApnSession -> ApnToken -> IO ApnMessageResult
- sendRawMessage :: ApnSession -> ApnToken -> ByteString -> IO ApnMessageResult
- alertMessage :: Text -> Text -> JsonApsMessage
- bodyMessage :: Text -> JsonApsMessage
- emptyMessage :: JsonApsMessage
- setAlertMessage :: Text -> Text -> JsonApsMessage -> JsonApsMessage
- setMessageBody :: Text -> JsonApsMessage -> JsonApsMessage
- setBadge :: Int -> JsonApsMessage -> JsonApsMessage
- setCategory :: Text -> JsonApsMessage -> JsonApsMessage
- setSound :: Text -> JsonApsMessage -> JsonApsMessage
- clearAlertMessage :: JsonApsMessage -> JsonApsMessage
- clearBadge :: JsonApsMessage -> JsonApsMessage
- clearCategory :: JsonApsMessage -> JsonApsMessage
- clearSound :: JsonApsMessage -> JsonApsMessage
- addSupplementalField :: ToJSON record => Text -> record -> JsonAps -> JsonAps
- closeSession :: ApnSession -> IO ()
- isOpen :: ApnSession -> IO Bool
- data ApnSession
- data JsonAps
- data JsonApsAlert
- data JsonApsMessage
- data ApnMessageResult
- data ApnFatalError
- = ApnFatalErrorBadCollapseId
- | ApnFatalErrorBadDeviceToken
- | ApnFatalErrorBadExpirationDate
- | ApnFatalErrorBadMessageId
- | ApnFatalErrorBadPriority
- | ApnFatalErrorBadTopic
- | ApnFatalErrorDeviceTokenNotForTopic
- | ApnFatalErrorDuplicateHeaders
- | ApnFatalErrorIdleTimeout
- | ApnFatalErrorMissingDeviceToken
- | ApnFatalErrorMissingTopic
- | ApnFatalErrorPayloadEmpty
- | ApnFatalErrorTopicDisallowed
- | ApnFatalErrorBadCertificate
- | ApnFatalErrorBadCertificateEnvironment
- | ApnFatalErrorExpiredProviderToken
- | ApnFatalErrorForbidden
- | ApnFatalErrorInvalidProviderToken
- | ApnFatalErrorMissingProviderToken
- | ApnFatalErrorBadPath
- | ApnFatalErrorMethodNotAllowed
- | ApnFatalErrorUnregistered
- | ApnFatalErrorPayloadTooLarge
- | ApnFatalErrorOther Text
- data ApnTemporaryError
- data ApnToken
Documentation
:: FilePath | Path to the client certificate key |
-> FilePath | Path to the client certificate |
-> FilePath | Path to the CA |
-> Bool | True if the apn development servers should be used, False to use the production servers |
-> Int | How many messages will be sent in parallel? This corresponds to the number of http2 streams open in parallel; 100 seems to be a default value. |
-> Int | How many connections to be opened at maximum. |
-> ByteString | Topic (bundle name of the app) |
-> IO ApnSession | The newly created session |
Start a new session for sending APN messages. A session consists of a connection pool of connections to the APN servers, while each connection has a pool of workers that create HTTP2 streams to send individual push notifications.
:: JsonApsMessage | The standard message to include |
-> JsonAps | The resulting APN message |
Prepare a new apn message consisting of a standard message without a custom payload
newMessageWithCustomPayload Source #
:: JsonApsMessage | The message |
-> Text | The custom payload |
-> JsonAps | The resulting APN message |
Prepare a new apn message consisting of a standard message and a custom payload
:: Text | The base16 (hex) encoded unique identifier for a device (APN token) |
-> ApnToken | The resulting token |
Create a token from a hex encoded text
:: ByteString | The bytestring that uniquely identifies a device (APN token) |
-> ApnToken | The resulting token |
Create a token from a raw bytestring
:: ApnSession | Session to use |
-> ApnToken | Device to send the message to |
-> JsonAps | The message to send |
-> IO ApnMessageResult | The response from the APN server |
Send a push notification message.
:: ApnSession | Session to use |
-> ApnToken | Device to send the message to |
-> IO ApnMessageResult | The response from the APN server |
Send a silent push notification
:: ApnSession | Session to use |
-> ApnToken | Device to send the message to |
-> ByteString | The message to send |
-> IO ApnMessageResult | The response from the APN server |
Send a raw payload as a push notification message (advanced)
:: Text | The title of the message |
-> Text | The body of the message |
-> JsonApsMessage | The modified message |
Create a new APN message with an alert part
:: Text | The body of the message |
-> JsonApsMessage | The modified message |
Create a new APN message with a body and no title
emptyMessage :: JsonApsMessage Source #
Create an empty apn message
:: Text | The title of the message |
-> Text | The body of the message |
-> JsonApsMessage | The message to alter |
-> JsonApsMessage | The modified message |
Set the alert part of an APN message
:: Text | The body of the message |
-> JsonApsMessage | The message to alter |
-> JsonApsMessage | The modified message |
Set the body of an APN message without affecting the title
:: Int | The badge number to set. The badge number is displayed next to your app's icon. Set to 0 to remove the badge number. |
-> JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Set the badge part of an APN message
:: Text | The category to set |
-> JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Set the category part of an APN message
:: Text | The sound to use (either "default" or something in the application's bundle) |
-> JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Set a sound for an APN message
:: JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Remove the alert part of an APN message
:: JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Clear the badge part of an APN message
:: JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Clear the category part of an APN message
:: JsonApsMessage | The message to modify |
-> JsonApsMessage | The modified message |
Clear the sound for an APN message
:: ToJSON record | |
=> Text | The field name |
-> record | The value |
-> JsonAps | The APN message to modify |
-> JsonAps | The resulting APN message |
Add a supplemental field to be sent over with the notification
NB: The field aps
must not be modified; attempting to do so will
cause a crash.
closeSession :: ApnSession -> IO () Source #
Manually close a session. The session must not be used anymore after it has been closed. Calling this function will close the worker thread, and all open connections to the APN service that belong to the given session. Note that sessions will be closed automatically when they are garbage collected, so it is not necessary to call this function.
isOpen :: ApnSession -> IO Bool Source #
Check whether a session is open or has been closed by a call to closeSession
data ApnSession Source #
A session that manages connections to Apple's push notification service
A push notification message
Instances
Show JsonAps Source # | |
Generic JsonAps Source # | |
ToJSON JsonAps Source # | |
Defined in Network.PushNotify.APN | |
type Rep JsonAps Source # | |
Defined in Network.PushNotify.APN type Rep JsonAps = D1 (MetaData "JsonAps" "Network.PushNotify.APN" "push-notify-apn-0.2.0.1-5OS6kJ5ChndFWKuLvfzIgT" False) (C1 (MetaCons "JsonAps" PrefixI True) (S1 (MetaSel (Just "jaAps") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 JsonApsMessage) :*: (S1 (MetaSel (Just "jaAppSpecificContent") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Text)) :*: S1 (MetaSel (Just "jaSupplementalFields") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Map Text Value))))) |
data JsonApsAlert Source #
The specification of a push notification's message body
Instances
data JsonApsMessage Source #
Push notification message's content
Instances
data ApnMessageResult Source #
The result of a send request
Instances
Eq ApnMessageResult Source # | |
Defined in Network.PushNotify.APN (==) :: ApnMessageResult -> ApnMessageResult -> Bool # (/=) :: ApnMessageResult -> ApnMessageResult -> Bool # | |
Show ApnMessageResult Source # | |
Defined in Network.PushNotify.APN showsPrec :: Int -> ApnMessageResult -> ShowS # show :: ApnMessageResult -> String # showList :: [ApnMessageResult] -> ShowS # |
data ApnFatalError Source #
Instances
Eq ApnFatalError Source # | |
Defined in Network.PushNotify.APN (==) :: ApnFatalError -> ApnFatalError -> Bool # (/=) :: ApnFatalError -> ApnFatalError -> Bool # | |
Show ApnFatalError Source # | |
Defined in Network.PushNotify.APN showsPrec :: Int -> ApnFatalError -> ShowS # show :: ApnFatalError -> String # showList :: [ApnFatalError] -> ShowS # | |
Generic ApnFatalError Source # | |
Defined in Network.PushNotify.APN type Rep ApnFatalError :: Type -> Type # from :: ApnFatalError -> Rep ApnFatalError x # to :: Rep ApnFatalError x -> ApnFatalError # | |
FromJSON ApnFatalError Source # | |
Defined in Network.PushNotify.APN parseJSON :: Value -> Parser ApnFatalError # parseJSONList :: Value -> Parser [ApnFatalError] # | |
type Rep ApnFatalError Source # | |
Defined in Network.PushNotify.APN type Rep ApnFatalError = D1 (MetaData "ApnFatalError" "Network.PushNotify.APN" "push-notify-apn-0.2.0.1-5OS6kJ5ChndFWKuLvfzIgT" False) ((((C1 (MetaCons "ApnFatalErrorBadCollapseId" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorBadDeviceToken" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorBadExpirationDate" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "ApnFatalErrorBadMessageId" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorBadPriority" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorBadTopic" PrefixI False) (U1 :: Type -> Type)))) :+: ((C1 (MetaCons "ApnFatalErrorDeviceTokenNotForTopic" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorDuplicateHeaders" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorIdleTimeout" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "ApnFatalErrorMissingDeviceToken" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorMissingTopic" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorPayloadEmpty" PrefixI False) (U1 :: Type -> Type))))) :+: (((C1 (MetaCons "ApnFatalErrorTopicDisallowed" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorBadCertificate" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorBadCertificateEnvironment" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "ApnFatalErrorExpiredProviderToken" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorForbidden" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorInvalidProviderToken" PrefixI False) (U1 :: Type -> Type)))) :+: ((C1 (MetaCons "ApnFatalErrorMissingProviderToken" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorBadPath" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorMethodNotAllowed" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "ApnFatalErrorUnregistered" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ApnFatalErrorPayloadTooLarge" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ApnFatalErrorOther" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))))))) |
data ApnTemporaryError Source #
ApnTemporaryErrorTooManyProviderTokenUpdates | |
ApnTemporaryErrorTooManyRequests | |
ApnTemporaryErrorInternalServerError | |
ApnTemporaryErrorServiceUnavailable | |
ApnTemporaryErrorShutdown |