j7w1 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3951e497a1e265f16c6c10956755d2c6be8c4781
4
- data.tar.gz: faf5275a3b266f6cb52ff1a2884a09d022c3d402
3
+ metadata.gz: 83d3f2bd8cde5d3e11d40a37b06dc0092b322811
4
+ data.tar.gz: d37d2f3da9f420cce773a18a4bacff0326c078b1
5
5
  SHA512:
6
- metadata.gz: 1ee6f0cc45bf8fd10101fbf659a5532175a865badf9cecdeeb1750dde99c57adeb18ea58696e2dbf94682d535a33345171fa8236fd75baee576c28580cebbe98
7
- data.tar.gz: 9df0889f3d0361b78cd96abaf3b5d375659df3f260cf72a52ed85c4c40e14f4b5dbb1ca13eb820e924c4549f121a550174d938680784594ae5f45681d74e1343
6
+ metadata.gz: 74afc75e3406e59f282a623b37f05899ab61157d8100593b72113cfdc428188ce3d26c69472fc9782f0171cded322a86812c74fe401bf0eecac068e62b82f514
7
+ data.tar.gz: 0e70ffa766a22f87473acb3495b75dd5ccf9d72c5d127aa77b577e9f5be7b5e55da46f6790a1aa6ba054b14af361d2112c6faa52a1da51977337e78c4f0113e3
@@ -6,17 +6,23 @@ module J7W1
6
6
 
7
7
  APNS_MAX_MESSAGE_SIZE = 40
8
8
 
9
- APS_TABLE = {
9
+ INPUT_PAYLOAD_TABLE = {
10
+ ios: {
10
11
  message: :alert,
11
12
  badge: :badge,
12
13
  sound: :sound,
13
- }.freeze
14
-
15
- ANDROID_TABLE = {
14
+ }.freeze,
15
+ android: {
16
16
  message: :message,
17
17
  badge: :badge,
18
18
  sound: :sound,
19
19
  data: :data,
20
+ }.freeze,
21
+ }.freeze
22
+
23
+ DEFAULT_SOUND_VALUE = {
24
+ android: true,
25
+ ios: 'default',
20
26
  }.freeze
21
27
 
22
28
  def create_ios_application(name, certs, private_key, options)
@@ -132,7 +138,7 @@ module J7W1
132
138
  end
133
139
 
134
140
  content = {
135
- aps: message_content_with_table(message_value, APS_TABLE),
141
+ aps: message_content(message_value, platform: :ios),
136
142
  }
137
143
  content.merge! data: data if data
138
144
 
@@ -143,12 +149,16 @@ module J7W1
143
149
  message_value.merge!(data: data)
144
150
  {
145
151
  GCM: {
146
- data: message_content_with_table(message_value, ANDROID_TABLE)
152
+ data: message_content(message_value, platform: :android),
147
153
  }.to_json
148
154
  }
149
155
  end
150
156
 
151
- def message_content_with_table(content, table)
157
+ def message_content(content, platform: nil)
158
+ table = INPUT_PAYLOAD_TABLE[platform]
159
+
160
+ content[:sound] = DEFAULT_SOUND_VALUE[platform] if content[:sound] == true
161
+
152
162
  table.keys.reduce({}) do |h, key|
153
163
  h[table[key]] = content[key]
154
164
  h
@@ -165,7 +175,7 @@ module J7W1
165
175
  end
166
176
 
167
177
  module_function :create_sns_client, :create_ios_application, :create_device_endpoint, :push,
168
- :payload_for, :ios_payload_for, :android_payload_for, :content_from, :message_content_with_table,
178
+ :payload_for, :ios_payload_for, :android_payload_for, :content_from, :message_content,
169
179
  :destroy_device_endpoint, :destroy_application_endpoint
170
180
  end
171
181
  end
@@ -1,3 +1,3 @@
1
1
  module J7W1
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: j7w1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - condor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk