Skip to content

groupme/em-wpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows Push Notification for EventMachine

Implements Windows Phone 7.1 and 8.0 push notifications as described on MSDN.

Usage

Toast

EM.run do
  toast = EM::WPN::Windows71::Toast.new("http://live.net...",
    :text1 => "Hello",
    :text2 => "World"
  )
  response = EM::WPN.push(toast)
end

Tile

EM.run do
  tile = EM::WPN::Windows71::Tile.new("http://live.net...",
    :background_image => "/image.png",
    :count            => 5,
    :title            => "Hello World"
  )
  response = EM::WPN.push(tile)
end

Windows Phone 8 tiles are available in additional classes:

  • EM::WPN::Windows8::IconicTile
  • EM::WPN::Windows8::FlipTile

Responses

Responses are implemented as EM deferrables. Callbacks are invoked whenever a tile or toast is successfully delivered:

response = EM::WPN.push(toast)
response.callback do |response|
  response.status      # => 200
  response.duration    # => ms
  response.http        # => EM::HttpClient
end

Errbacks are invoked for any non-200 response as well as network errors:

response = EM::WPN.push(tile)
response.errback do |response|
  response.status      # => e.g. 404 (nil for connection errors)
  response.error       # => Notification status or connection error
end

TODO

  • Raw notifications
  • SSL request signing (see this)

Credits

This is a direct clone of Dave Yeu's em-apn gem.

About

EventMachine-driven Windows Phone Push Notifications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages