push_to_sns 0.1.1 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb88b92dcd3dc7f89ad71992c1f05bcb496765f
|
4
|
+
data.tar.gz: 2c64da57edee3c5d6a8b668b26fde82861a6c89e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e11f5cbead59e666895f74ce48f5dbb1b2964c74a304acad1694751876ad955bc6cf0230ffca7cff0dfb4af1438e6b7e4f47afad0ef763497e3b80a84819f197
|
7
|
+
data.tar.gz: d3da5122c6ac0d62601d7d22fc009671b423de37cbc0de4d2f29eda298f310f159f1e860a14718751c19db011c7e6583afa9aab83cb0fe5f9127ea442998255b
|
@@ -9,9 +9,13 @@ module PushToSNS
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def default_payload
|
12
|
-
{
|
12
|
+
basic_message = {
|
13
13
|
message: payload[:message] || DEFAULT_MESSAGE
|
14
14
|
}
|
15
|
+
basic_message[:smallIcon] = payload[:badge] if payload[:badge]
|
16
|
+
basic_message[:sound] = payload[:sound] if payload[:sound]
|
17
|
+
|
18
|
+
basic_message
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -3,12 +3,18 @@ module PushToSNS
|
|
3
3
|
DEFAULT_MESSAGE = "IOS Push Notification"
|
4
4
|
|
5
5
|
def message
|
6
|
-
{
|
6
|
+
basic_message = {
|
7
7
|
apns => {
|
8
|
-
aps: {
|
8
|
+
aps: {
|
9
|
+
alert: payload[:message] || DEFAULT_MESSAGE
|
10
|
+
},
|
9
11
|
data: payload
|
10
|
-
}
|
12
|
+
}
|
11
13
|
}
|
14
|
+
basic_message[apns][:aps][:badge] = payload[:badge] if payload[:badge]
|
15
|
+
basic_message[apns][:aps][:sound] = payload[:sound] if payload[:sound]
|
16
|
+
basic_message[apns] = basic_message[apns].to_json
|
17
|
+
basic_message
|
12
18
|
end
|
13
19
|
|
14
20
|
private
|
@@ -23,7 +23,12 @@ module PushToSNS
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def full_notification_for_device(device)
|
26
|
-
defaults = {
|
26
|
+
defaults = {
|
27
|
+
type: call_or_read(type, device),
|
28
|
+
message: call_or_read(message, device),
|
29
|
+
badge: call_or_read(badge, device),
|
30
|
+
sound: call_or_read(sound, device)
|
31
|
+
}.reject { |key, value| value.nil? }
|
27
32
|
defaults.merge(notification(device))
|
28
33
|
end
|
29
34
|
|
@@ -35,22 +40,37 @@ module PushToSNS
|
|
35
40
|
@message ||= self.class.message
|
36
41
|
end
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
def badge
|
44
|
+
@badge ||= self.class.badge
|
45
|
+
end
|
40
46
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
def sound
|
48
|
+
@sound ||= self.class.sound
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def call_or_read(proc_or_object, *arguments)
|
54
|
+
if proc_or_object.respond_to?(:call)
|
55
|
+
proc_or_object.call(*arguments)
|
56
|
+
else
|
57
|
+
proc_or_object
|
47
58
|
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
[:type, :message, :badge, :sound].each do |method_name|
|
63
|
+
property_name = "input_#{method_name}".to_sym
|
64
|
+
attr_accessor property_name
|
48
65
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
66
|
+
define_method(method_name) do |input = nil, &block|
|
67
|
+
if input.nil? && block.nil?
|
68
|
+
public_send(property_name)
|
69
|
+
elsif input.nil? && !block.nil?
|
70
|
+
public_send("#{property_name}=", block)
|
71
|
+
elsif !input.nil?
|
72
|
+
public_send("#{property_name}=", input)
|
73
|
+
end
|
54
74
|
end
|
55
75
|
end
|
56
76
|
end
|
data/lib/push_to_sns/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: push_to_sns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|