apnd 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,9 +90,41 @@ push notifications to APND.
90
90
  )
91
91
 
92
92
 
93
+ ## Prerequisites
94
+
95
+ You must have a valid Apple Push Notification Certificate for your iPhone
96
+ application. Obtain your APN certificate from the iPhone Provisioning Portal
97
+ at [developer.apple.com](http://developer.apple.com/).
98
+
99
+
100
+ ## Requirements
101
+
102
+ * [EventMachine](http://github.com/eventmachine/eventmachine)
103
+ * [Daemons](http://github.com/ghazel/daemons)
104
+ * [JSON](http://github.com/flori/json)
105
+
106
+ Ruby must be compiled with OpenSSL support.
107
+
108
+
109
+ ## Installation
110
+
111
+ RubyGems:
112
+
113
+ gem install apnd
114
+
115
+ Git:
116
+
117
+ git clone git://github.com/itspriddle/apnd.git
118
+
119
+
93
120
  ## Credit
94
121
 
95
122
  APND is based on [apnserver](http://github.com/bpoweski/apnserver) and
96
123
  [apn_on_rails](http://github.com/PRX/apn_on_rails). Either worked just how I
97
124
  wanted, so I rolled my own using theirs as starting points. If APND doesn't
98
125
  suit you, check them out instead.
126
+
127
+
128
+ ## Copyright
129
+
130
+ Copyright (c) 2010 Joshua Priddle. See LICENSE for details.
@@ -120,11 +120,11 @@ module APND
120
120
  #
121
121
  # Returns the Notification's aps hash as json
122
122
  #
123
- def payload
124
- return @payload if @payload
123
+ def aps_json
124
+ return @aps_json if @aps_json
125
125
  json = aps.to_json
126
126
  raise APND::InvalidPayload.new(json) if json.size > 256
127
- @payload = json
127
+ @aps_json = json
128
128
  end
129
129
 
130
130
  #
@@ -132,7 +132,7 @@ module APND
132
132
  # to Apple
133
133
  #
134
134
  def to_bytes
135
- @bytes ||= "\0\0 %s\0%s%s" % [hex_token, payload.length.chr, payload]
135
+ @bytes ||= "\0\0 %s\0%s%s" % [hex_token, aps_json.length.chr, aps_json]
136
136
  end
137
137
 
138
138
  end
@@ -1,8 +1,8 @@
1
1
  module APND
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 3
4
+ MINOR = 1
5
+ TINY = 0
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, TINY].join('.')
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
- context "APND Daemon" do
4
-
5
- end
3
+ # context "APND Daemon" do
4
+ #
5
+ # end
@@ -1,5 +1,29 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  context "APND Notification" do
4
+ setup do
5
+ @bytes = %|\000\000 \376\025\242}]\363\303Gx\336\373\037O8\200&\\\305,\f\004v\202";\345\237\266\205\000\251\242\000;{"aps":{"sound":"default","alert":"Red Alert, Numba One!"}}|
6
+ @notification = APND::Notification.new({
7
+ :token => 'fe15a27d5df3c34778defb1f4f3880265cc52c0c047682223be59fb68500a9a2',
8
+ :alert => 'Red Alert, Numba One!'
9
+ })
10
+ end
11
+
12
+ test "returns a properly formatted hex_token" do
13
+ expected = %|\376\025\242}]\363\303Gx\336\373\037O8\200&\\\305,\f\004v\202";\345\237\266\205\000\251\242|
14
+ assert_equal @notification.hex_token, expected
15
+ end
16
+
17
+ test "returns a properly formatted byte string for Apple" do
18
+ assert_equal @notification.to_bytes, @bytes
19
+ end
20
+
21
+ test "returns a Notification object when given valid byte string" do
22
+ notification = APND::Notification.parse(@bytes)
23
+
24
+ [:alert, :badge, :custom, :sound, :token, :hex_token, :to_bytes, :aps, :aps_json].each do |key|
25
+ assert_equal @notification.send(key), notification.send(key)
26
+ end
27
+ end
4
28
 
5
29
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua Priddle