push-notifications-0.2.1: Push notifications for Android and iOS

Safe HaskellNone
LanguageHaskell2010

Network.PushNotification.IOS

Description

Apple Push Notification Service provider

Sending push notifications requires an "Apple Push Services" certificate and an Apple-provided device token.

Getting an APS Certificate

The APS certificate is produced in the iOS Provisioning Portal. Once you've generated the certificate, you can download it from the Provisioning Portal. It is usually named aps_production.cer or aps_development.cer.

The private key for the certificate can be extracted from Apple's Keychain utility as a .p12 file.

Once you have both the certificate and private key, the following commands can be used to convert the certificate and private key files into the format required by this library.

openssl x509 -in aps_development.cer -inform DER -outform PEM -out cert.pem
openssl pkcs12 -in key.p12 -out key.pem -nodes

Getting a Device Token

Device tokens are retrieved from Apple on the device itself by calling the registerForRemoteNotifications method of the UIApplication object. For more information, please see Apple's documentation here.

Credits

Originally based on a blog post by Teemu Ikonen, available here.

Synopsis

Documentation

withAPNSSocket :: APNSConfig -> (SSL -> IO ()) -> IO () Source #

Opens an APNS connection, runs the supplied action with the SSL socket, and closes the connection.

Example usage:

withAPNSSocket cfg $ \sslsocket -> sendApplePushMessage msg sslsocket

Note that in practice you should keep the SSL socket open and re-use it. From the Apple documentation: "APNs treats rapid connection and disconnection as a denial-of-service attack."

sendApplePushMessage :: SSL -> ApplePushMessage -> IO () Source #

Send a message through the SSL socket