push-notify-0.1.0.0: Network/PushNotify/Mpns/README.md
## API for communicating through MPNS
I developed an API for communicating through MPNS with Windows Phone mobile devices ([1](https://github.com/MarcosPividori/GSoC-Communicating-with-mobile-devices/tree/master/push-notify/Network/PushNotify/Mpns)). For this, I designed a way of building the messages, sending them and handling the result.
To communicate with MPNS servers, I need to send POST requests, so I decided to use Conduit, as I have done with GCM. The MPNS Api looks like this:
MPNS let you send notification in an authenticated or unauthenticated mode, so you can configure this with MPNSConfig:
data MPNSConfig = MPNSConfig{
numRet :: Int
, useSecure :: Bool
, certificate :: X509
, privateKey :: PrivateKey
}
To build messages, I developed a data type "MPNSmessage"
data MPNSmessage = MPNSmessage{
deviceURIs :: HashSet DeviceURI -- destinations
, batching_interval :: MPNSInterval -- Immediate | Sec450 | Sec900
, target :: MPNSType -- Toast | Raw | Tile
, restXML :: Document -- the XML data to be sent
}
For sending notifications:
sendMPNS :: Manager -> MPNSConfig -> MPNSmessage -> IO MPNSresult
Last, for handling the result:
data MPNSresult = MPNSresult{
successfullResults :: HashMap DeviceURI MPNSinfo
, errorException :: HashMap DeviceURI SomeException
}
The code is available on GitHub:
- The MPNS Api : [1]("https://github.com/MarcosPividori/GSoC-Communicating-with-mobile-devices/tree/master/push-notify/Network/PushNotify/Mpns")
- Test example for MPNS: [2]("https://github.com/MarcosPividori/GSoC-Communicating-with-mobile-devices/tree/master/push-notify/test")
- Yesod and MPNS app example: [3](https://github.com/MarcosPividori/GSoC-Communicating-with-mobile-devices/tree/master/test)
For more information about:
- The MPNS Service:
(http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558(v=vs.105).aspx)
- The communication with MPNS servers:
(http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202945(v=vs.105).aspx)