pntfr 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pntfr/session/ios.rb +6 -5
- data/lib/pntfr/version.rb +4 -1
- data/test/pntfr/device.rb +2 -1
- data/test/pntfr/ios_badge_test.rb +19 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2050d1fa6a4e3cecd3fb3772478b0510daafeb4a
|
4
|
+
data.tar.gz: 220bbae6b5b10ecc513ded32c49eb9b884b6d298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2bff68fd2e597f4bb74dfe7092ccfd6397ad0084e6c5ba8ba1d404c34e5d7604b94aa0ce9eb774b049470dcffd345a907a3a39aff3db0d0ef5272b281e4e8c
|
7
|
+
data.tar.gz: 3fd175f1d640ec77c87cf19d344eef86958dbd2aba4aa5a5f91e69fa135697388d0e6e7eda2ef76e152c35ef8aa7f17dc3e2328cbea5f2ed806f6f1900d6fa7c
|
data/lib/pntfr/session/ios.rb
CHANGED
@@ -15,22 +15,23 @@ module Pntfr
|
|
15
15
|
def notify devices, notification
|
16
16
|
apns_notifications= []
|
17
17
|
devices.each do |device|
|
18
|
+
dev_notif= notification.dup
|
18
19
|
if device_controls_badge(device)
|
19
|
-
if !
|
20
|
-
device.num_notifs=
|
20
|
+
if !dev_notif[:badge].nil?
|
21
|
+
device.num_notifs= dev_notif[:badge]
|
21
22
|
else
|
22
23
|
if device.methods.include?(:increment!)
|
23
24
|
device.increment!(:num_notifs)
|
24
25
|
else
|
25
26
|
device.num_notifs+= 1
|
26
27
|
end
|
27
|
-
|
28
|
+
dev_notif[:badge]= device.num_notifs
|
28
29
|
end
|
29
30
|
end
|
30
31
|
if Pntfr.test_env?
|
31
|
-
Pntfr.add_delivery(device.push_id,
|
32
|
+
Pntfr.add_delivery(device.push_id, dev_notif)
|
32
33
|
else
|
33
|
-
apns_notif= APNS::Notification.new(device.push_id,
|
34
|
+
apns_notif= APNS::Notification.new(device.push_id, dev_notif)
|
34
35
|
apns_notifications << apns_notif
|
35
36
|
end
|
36
37
|
end
|
data/lib/pntfr/version.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
# Let's follow Semantic Versioning: http://semver.org/
|
3
3
|
#
|
4
4
|
module Pntfr
|
5
|
+
#
|
6
|
+
# PATCH v0.5.2
|
7
|
+
# - Fix. [FIX] Increase badge independently for each device.
|
5
8
|
#
|
6
9
|
# PATCH v0.5.1
|
7
10
|
# - Use increment! instead of increment when incrementing badge on a device object
|
@@ -22,5 +25,5 @@ module Pntfr
|
|
22
25
|
# - Allow overriding general configuration credentials when instantiating each
|
23
26
|
# Notifier (on both platforms).
|
24
27
|
# - Internal refactoring.
|
25
|
-
VERSION = '0.5.
|
28
|
+
VERSION = '0.5.2'
|
26
29
|
end
|
data/test/pntfr/device.rb
CHANGED
@@ -7,6 +7,7 @@ Pntfr::IosDevice= Struct.new(:platform, :push_id, :num_notifs)
|
|
7
7
|
# A device class that quacks like ActiveRecord with num_notifs which will be autoincremented on each sent msg
|
8
8
|
class Pntfr::ArIosDevice < Pntfr::IosDevice
|
9
9
|
def increment!(attr_name, by=1)
|
10
|
-
self.send("#{attr_name}
|
10
|
+
val= self.send("#{attr_name}")
|
11
|
+
self.send("#{attr_name}=", val.to_i + by)
|
11
12
|
end
|
12
13
|
end
|
@@ -7,9 +7,7 @@ module Pntfr
|
|
7
7
|
|
8
8
|
Pntfr::Notifier.to(device).msg({:title => 't', :description => 'd'}).notify
|
9
9
|
|
10
|
-
|
11
|
-
notif= notifs.last
|
12
|
-
assert_equal 1, notif[:badge]
|
10
|
+
check_badge(1, '1id2id3id4id5id')
|
13
11
|
assert_equal 1, device.num_notifs
|
14
12
|
end
|
15
13
|
def test_sending_a_notification_increments_notifier_notifications_num_on_active_record_devices
|
@@ -17,10 +15,25 @@ module Pntfr
|
|
17
15
|
|
18
16
|
Pntfr::Notifier.to(device).msg({:title => 't', :description => 'd'}).notify
|
19
17
|
|
20
|
-
|
21
|
-
notif= notifs.last
|
22
|
-
assert_equal 1, notif[:badge]
|
18
|
+
check_badge(1, '1ar2ar3ar4ar5ar')
|
23
19
|
assert_equal 1, device.num_notifs
|
24
20
|
end
|
21
|
+
def test_sending_a_notification_to_devices_with_different_badge_should_send_different_badge_for_each_device
|
22
|
+
devices= [Pntfr::ArIosDevice.new(Pntfr::Platforms::IOS, '1badge', 1),
|
23
|
+
Pntfr::ArIosDevice.new(Pntfr::Platforms::IOS, '2badge', 2)]
|
24
|
+
|
25
|
+
Pntfr::Notifier.to(devices).msg({:title => 'MultiBadge', :description => 'Test'}).notify
|
26
|
+
|
27
|
+
check_badge(2, '1badge')
|
28
|
+
check_badge(3, '2badge')
|
29
|
+
end
|
30
|
+
###################################################
|
31
|
+
private
|
32
|
+
###################################################
|
33
|
+
def check_badge(expected_badge, push_id)
|
34
|
+
notifs= Pntfr.deliveries[push_id]
|
35
|
+
notif= notifs.last
|
36
|
+
assert_equal expected_badge, notif[:badge], "Nofication for device [#{push_id}] should have expected badge"
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pntfr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apns
|