Permalink
Browse files

Add license, update readme and add sample_usage.

  • Loading branch information...
1 parent 2bae302 commit 1ce5312be704107396655fb8a9405966439e3744 @nverinaud committed Jun 10, 2012
Showing with 134 additions and 31 deletions.
  1. +20 −0 LICENSE
  2. +60 −3 README.md
  3. +1 −0 VERSION
  4. +2 −0 lib/microsoft_push_notification_service.rb
  5. +0 −28 main.rb
  6. +51 −0 sample_usage.rb
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright 2012 Nicolas VERINAUD
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,4 +1,61 @@
-ruby-mpns
-=========
+# ruby-mpns
+
+A ruby library to communicate with Microsoft Push Notification Service.
+
+## Installing
+
+Currently it is just a simple library.
+Drop the file `lib/microsoft_push_notification_service.rb` in your project and include it with `require`.
+
+**Warning !!**: this lib requires `htmlentities` gem to work. You find it [here](https://github.com/threedaymonk/htmlentities)
+or install it using `gem install htmlentities`.
+
+## Usage
+
+See `sample_usage.rb` for samples.
+
+## Parameters
+
+### Toast notification
+
+The following notification parameters can be defined in the options hash for `:toast`:
+
+* `title` - the title
+* `content` - the content
+* `params` - a hash that will be transformed into `key1=value1&key2=value2...`
+
+### Raw notification
+
+You can pass whatever hash you want and an XML will be generated, like the following:
+
+ <root>
+ <key1>value1</key1>
+ <key2>value2</key2>
+ </root>
+
+**Warning**: currently limited to one level, the hash must not contain another hash.
+
+### Tile notification
+
+The following notification parameters can be defined in the options hash for `:tile`:
+
+* `title` - the title
+* `count` - the badge to display on the app tile
+* `background_image` - the path to a local image embedded in the app or an image accessible via HTTP (.jpg or .png, 173x137px, max 80kb)
+* `back_title` - the title when the tile is flipped
+* `back_background_image` - the path to a local image embedded in the app or an image accessible via HTTP (.jpg or .png, 173x137px, max 80kb)
+* `back_content` - the content when the tile is flipped
+
+## Reference
+
+For general information about Push Notification on Windows Phone check the [MSDN](http://msdn.microsoft.com/en-us/library/hh202945(v=vs.92).aspx).
+
+## Todo
+
+* Make this lib a gem
+* Add unit tests
+* Add support for multi-level hash for raw notifications
+
+Copyright (c) 2012 [Nicolas VERINAUD](http://www.nverinaud.com). Released under the MIT license.
+
-A ruby gem to communicate with Microsoft Push Notification Service.
View
@@ -0,0 +1 @@
+0.9-beta
@@ -137,6 +137,8 @@ def raw_notification_with_options options = {}
notification << '<' << coder.encode(key.to_s) << '>' << coder.encode(value.to_s) << '</' << coder.encode(key.to_s) << '>'
end
notification << '</root>'
+
+ puts notification
return notification
end
View
28 main.rb
@@ -1,28 +0,0 @@
-# encoding: utf-8
-
-require File.dirname(__FILE__) + '/lib/microsoft_push_notification_service'
-
-puts "=== Test ==="
-
-options = {
- title: "Hi there",
- content: "Yay bro héhé <nice>",
- params: {
- invoice_id: 2,
- state: "waiting",
- dummy_key: "noob",
- another: '"hey hey"'
- }
-}
-
-uri = "http://sn1.notify.live.net/throttledthirdparty/01.00/AAEaEI26DywTQoTyuwfn7r2lAgAAAAADAQAAAAQUZm52OjIzOEQ2NDJDRkI5MEVFMEQ"
-
-# MicrosoftPushNotificationService.send_notification uri, :toast, options
-
-options = {
- table_id: 2,
- dummy: 1
-}
-
-response = MicrosoftPushNotificationService.send_notification uri, :raw, options
-puts response
View
@@ -0,0 +1,51 @@
+# encoding: utf-8
+
+require File.dirname(__FILE__) + '/lib/microsoft_push_notification_service'
+
+puts "=== Test ==="
+
+uri = "<# Your Microsoft Push URI here #>"
+
+#
+# => TOAST
+#
+options = {
+ title: "Hi there",
+ content: "Testing <correct> encoding of special &éà chars.",
+ params: {
+ invoice_id: 2,
+ state: 10.5,
+ another: '"hey hey"'
+ }
+}
+
+response = MicrosoftPushNotificationService.send_notification uri, :toast, options
+puts response
+
+
+#
+# => RAW
+#
+options = { # Only on level is currently supported for raw notification, feel free to improve !
+ anykey: "anyvalue",
+ otherkey: "whynot"
+}
+
+response = MicrosoftPushNotificationService.send_notification uri, :raw, options
+puts response
+
+
+#
+# => TILE
+#
+options = {
+ title: "Hello World !",
+ background_image: "local/hello.png",
+ count: 12,
+ back_title: "! dlroW olleH",
+ back_background_image: "local/olleh.png",
+ back_content: "! hcuoA"
+}
+
+response = MicrosoftPushNotificationService.send_notification uri, :tile, options
+puts response

0 comments on commit 1ce5312

Please sign in to comment.