pntfr 0.4.1 → 0.5.0
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/README.md +15 -2
- data/lib/pntfr/session/ios.rb +5 -1
- data/lib/pntfr/version.rb +7 -1
- data/test/pntfr/device.rb +6 -0
- data/test/pntfr/ios_badge_test.rb +11 -1
- 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: e851e22201a25b2535b8da2b6543a752483553c7
|
4
|
+
data.tar.gz: 0b725ce8bc511327f58078de1cde59fd0961462e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65725eb135334b436031f3f36bd1353497d62dab244f7da49dfbd2cf59e2aa72ced7993f55269969bdeacdd93fdd34c384bac500cffcc71a034a33a0bcda9876
|
7
|
+
data.tar.gz: 82f8acb3146919185317497b33171cfe9654775dbfce95b055490de196f149ef537b5191ade9042152fb04251290d776d41b513a53a8ffa885546468128acade
|
data/README.md
CHANGED
@@ -46,7 +46,9 @@ end
|
|
46
46
|
## Sending messages
|
47
47
|
Pntfr suposes you have device objects, or other kind of model, with `platform` and `push_id` attributes.
|
48
48
|
Also, and optionally, a `num_notifs` integer attribute will be automagically managed to
|
49
|
-
monitor Apple's badge in notifications
|
49
|
+
monitor Apple's badge in notifications (for device objects with an `increment` method
|
50
|
+
(like ActiveRecord;) will use `increment(:num_notifs)`, for non ActiveRecord like
|
51
|
+
device objects `num_notifs+= 1` will be used).
|
50
52
|
|
51
53
|
In order to avoid having to create a different message for each platform Pntfr
|
52
54
|
expects a "neutral format" for the messages. The neutral format of the messages
|
@@ -101,7 +103,18 @@ notifier.msg(
|
|
101
103
|
}
|
102
104
|
)
|
103
105
|
notifier.notify
|
104
|
-
|
106
|
+
# for IOS will result in the adding the custom content in the msg this way:
|
107
|
+
msg[:other][:custom]= {
|
108
|
+
:extra1 => 'extra one',
|
109
|
+
:extra_2 => 'extra 2',
|
110
|
+
:'last-extra' => {lastkey: 'last value'}
|
111
|
+
}
|
112
|
+
# for ANDROID will result in the adding the custom content in the msg this way:
|
113
|
+
msg[:custom]= {
|
114
|
+
:extra1 => 'extra one',
|
115
|
+
:extra_2 => 'extra 2',
|
116
|
+
:'last-extra' => {lastkey: 'last value'}
|
117
|
+
}
|
105
118
|
|
106
119
|
# SETTING ANPS AND GCN CREDENTIALS ON EACH NOTIFICATION
|
107
120
|
# using different configuration on each call
|
data/lib/pntfr/session/ios.rb
CHANGED
@@ -19,7 +19,11 @@ module Pntfr
|
|
19
19
|
if !notification[:badge].nil?
|
20
20
|
device.num_notifs= notification[:badge]
|
21
21
|
else
|
22
|
-
device.
|
22
|
+
if device.methods.include?(:increment)
|
23
|
+
device.increment(:num_notifs)
|
24
|
+
else
|
25
|
+
device.num_notifs+= 1
|
26
|
+
end
|
23
27
|
notification[:badge]= device.num_notifs
|
24
28
|
end
|
25
29
|
end
|
data/lib/pntfr/version.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# Let's follow Semantic Versioning: http://semver.org/
|
3
|
+
#
|
1
4
|
module Pntfr
|
5
|
+
#
|
6
|
+
# MINOR v0.5.0
|
7
|
+
# - Badge control now can use ActiveRecord's increment method.
|
2
8
|
#
|
3
9
|
# PATCH v0.4.1
|
4
10
|
# - Republish gem after gem yanking it.
|
@@ -12,5 +18,5 @@ module Pntfr
|
|
12
18
|
# - Allow overriding general configuration credentials when instantiating each
|
13
19
|
# Notifier (on both platforms).
|
14
20
|
# - Internal refactoring.
|
15
|
-
VERSION = '0.
|
21
|
+
VERSION = '0.5.0'
|
16
22
|
end
|
data/test/pntfr/device.rb
CHANGED
@@ -4,3 +4,9 @@
|
|
4
4
|
Pntfr::Device= Struct.new(:platform, :push_id)
|
5
5
|
# device with num_notifs which will be autoincremented on each sent msg
|
6
6
|
Pntfr::IosDevice= Struct.new(:platform, :push_id, :num_notifs)
|
7
|
+
# A device class that quacks like ActiveRecord with num_notifs which will be autoincremented on each sent msg
|
8
|
+
class Pntfr::ArIosDevice < Pntfr::IosDevice
|
9
|
+
def increment(attr_name, by=1)
|
10
|
+
self.send("#{attr_name}=", by)
|
11
|
+
end
|
12
|
+
end
|
@@ -2,7 +2,7 @@ require 'pntfr/device'
|
|
2
2
|
|
3
3
|
module Pntfr
|
4
4
|
class IosBadgeTest < Minitest::Test
|
5
|
-
def
|
5
|
+
def test_sending_a_notification_increments_notifier_notifications_num_on_non_active_record_devices
|
6
6
|
device= Pntfr::IosDevice.new(Pntfr::Platforms::IOS, '1id2id3id4id5id', 0)
|
7
7
|
|
8
8
|
Pntfr::Notifier.to(device).msg({:title => 't', :description => 'd'}).notify
|
@@ -12,5 +12,15 @@ module Pntfr
|
|
12
12
|
assert_equal 1, notif[:badge]
|
13
13
|
assert_equal 1, device.num_notifs
|
14
14
|
end
|
15
|
+
def test_sending_a_notification_increments_notifier_notifications_num_on_active_record_devices
|
16
|
+
device= Pntfr::ArIosDevice.new(Pntfr::Platforms::IOS, '1ar2ar3ar4ar5ar', 0)
|
17
|
+
|
18
|
+
Pntfr::Notifier.to(device).msg({:title => 't', :description => 'd'}).notify
|
19
|
+
|
20
|
+
notifs= Pntfr.deliveries['1ar2ar3ar4ar5ar']
|
21
|
+
notif= notifs.last
|
22
|
+
assert_equal 1, notif[:badge]
|
23
|
+
assert_equal 1, device.num_notifs
|
24
|
+
end
|
15
25
|
end
|
16
26
|
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.
|
4
|
+
version: 0.5.0
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apns
|