rapns 2.0.0rc2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -1
- data/README.md +3 -0
- data/lib/rapns/notification.rb +2 -1
- data/lib/rapns/version.rb +1 -1
- data/spec/rapns/notification_spec.rb +4 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -160,3 +160,6 @@ Thank you to the following wonderful people for contributing to rapns:
|
|
160
160
|
* [@sjmadsen](https://github.com/sjmadsen)
|
161
161
|
* [@ivanyv](https://github.com/ivanyv)
|
162
162
|
* [@taybenlor](https://github.com/taybenlor)
|
163
|
+
* [@tompesman](https://github.com/tompesman)
|
164
|
+
* [@EpicDraws](https://github.com/EpicDraws)
|
165
|
+
* [@dei79](https://github.com/dei79)
|
data/lib/rapns/notification.rb
CHANGED
@@ -2,6 +2,7 @@ module Rapns
|
|
2
2
|
class Notification < ActiveRecord::Base
|
3
3
|
self.table_name = 'rapns_notifications'
|
4
4
|
|
5
|
+
validates :app, :presence => true
|
5
6
|
validates :device_token, :presence => true
|
6
7
|
validates :badge, :numericality => true, :allow_nil => true
|
7
8
|
validates :expiry, :numericality => true, :presence => true
|
@@ -81,7 +82,7 @@ module Rapns
|
|
81
82
|
# http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW4
|
82
83
|
def to_binary(options = {})
|
83
84
|
id_for_pack = options[:for_validation] ? 0 : id
|
84
|
-
[1, id_for_pack, expiry, 0, 32, device_token,
|
85
|
+
[1, id_for_pack, expiry, 0, 32, device_token, payload_size, payload].pack("cNNccH*na*")
|
85
86
|
end
|
86
87
|
end
|
87
88
|
end
|
data/lib/rapns/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Rapns::Notification do
|
4
|
+
it { should validate_presence_of(:app) }
|
4
5
|
it { should validate_presence_of(:device_token) }
|
5
6
|
it { should validate_numericality_of(:badge) }
|
6
7
|
it { should validate_numericality_of(:expiry) }
|
@@ -126,6 +127,7 @@ describe Rapns::Notification, "to_binary" do
|
|
126
127
|
notification.alert = "Don't panic Mr Mainwaring, don't panic!"
|
127
128
|
notification.attributes_for_device = {:hi => :mom}
|
128
129
|
notification.expiry = 86400 # 1 day, \x00\x01Q\x80
|
130
|
+
notification.app = 'my_app'
|
129
131
|
notification.save!
|
130
132
|
notification.stub(:id).and_return(1234)
|
131
133
|
notification.to_binary.should == "\x01\x00\x00\x04\xD2\x00\x01Q\x80\x00 \xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\x00a{\"aps\":{\"alert\":\"Don't panic Mr Mainwaring, don't panic!\",\"badge\":3,\"sound\":\"1.aiff\"},\"hi\":\"mom\"}"
|
@@ -152,9 +154,10 @@ describe Rapns::Notification, "bug #35" do
|
|
152
154
|
notification = Rapns::Notification.new do |n|
|
153
155
|
n.device_token = "a" * 64
|
154
156
|
n.alert = "a" * 210
|
157
|
+
n.app = 'my_app'
|
155
158
|
end
|
156
159
|
|
157
|
-
notification.to_binary(:for_validation => true).
|
160
|
+
notification.to_binary(:for_validation => true).bytesize.should > 256
|
158
161
|
notification.payload_size.should < 256
|
159
162
|
notification.should be_valid
|
160
163
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ian Leitch
|
@@ -83,9 +83,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
|
-
- - ! '
|
86
|
+
- - ! '>='
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.23
|