rapnd 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rapnd/notification.rb +4 -4
- data/rapnd.gemspec +1 -1
- data/spec/notification_spec.rb +6 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/rapnd/notification.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Rapnd
|
2
2
|
class Notification
|
3
|
-
attr_accessor :badge, :alert, :sound, :
|
3
|
+
attr_accessor :badge, :alert, :sound, :content_available, :custom_properties, :device_token
|
4
4
|
|
5
5
|
def initialize(hash)
|
6
|
-
[:badge, :alert, :sound, :device_token, :custom_properties].each do |k|
|
6
|
+
[:badge, :alert, :sound, :device_token, :content_available, :custom_properties].each do |k|
|
7
7
|
self.instance_variable_set("@#{k}".to_sym, hash[k]) if hash[k]
|
8
8
|
end
|
9
9
|
raise "Must provide device token: #{hash}" if self.device_token.nil?
|
@@ -12,8 +12,8 @@ module Rapnd
|
|
12
12
|
|
13
13
|
def payload
|
14
14
|
p = Hash.new
|
15
|
-
[:badge, :alert, :sound, :
|
16
|
-
p[k] = send(k) if send(k)
|
15
|
+
[:badge, :alert, :sound, :content_available].each do |k|
|
16
|
+
p[k.to_s.gsub('_','-').to_sym] = send(k) if send(k)
|
17
17
|
end
|
18
18
|
aps = {:aps => p}
|
19
19
|
aps.merge!(custom_properties) if custom_properties
|
data/rapnd.gemspec
CHANGED
data/spec/notification_spec.rb
CHANGED
@@ -9,6 +9,12 @@ describe "Rapnd::Notification" do
|
|
9
9
|
@notification.device_token.should == '12345'
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'sets a content-available' do
|
13
|
+
@notification = Rapnd::Notification.new(:alert => 'Big test time', :content_available => "Yes!", :custom_properties => {:key => 'This is a test!', :spid => 1234}, :device_token => '1234 5')
|
14
|
+
|
15
|
+
@notification.payload.should == {:aps => {:alert => "Big test time", :'content-available' => "Yes!"}, :key => "This is a test!", :spid => 1234}
|
16
|
+
end
|
17
|
+
|
12
18
|
it 'does not set the body key if only an alert is passed' do
|
13
19
|
@notification = Rapnd::Notification.new(:alert => 'Big test time', :custom_properties => {:key => 'This is a test!', :spid => 1234}, :device_token => '1234 5')
|
14
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapnd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -231,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
segments:
|
233
233
|
- 0
|
234
|
-
hash: -
|
234
|
+
hash: -3943854128204889530
|
235
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
236
|
none: false
|
237
237
|
requirements:
|