j7w1 0.0.17 → 0.0.18
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/j7w1.rb +7 -6
- data/lib/j7w1/sns_push_client.rb +21 -7
- data/lib/j7w1/version.rb +1 -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: c1a71b5172329b1a6d8ee0fb802550a281603a64
|
4
|
+
data.tar.gz: b1ab7f15f14a6c33192ae52f1a49264e2d4ddb91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e3f78f9fcfbaab49c2678469569d84c716c03579506ee345db909eba02324d2aa03aaf5c7258d710a7e1716f436bd3266e03eec09078a663d19287fed9ea163
|
7
|
+
data.tar.gz: e994c3b606b851329e6222b7827821ae713edec0f97ff99c766c814c3451da979b8ab1f0ef1d8dd50d91106e6504c1690d1fecf6912442f546209abefc0687a0
|
data/lib/j7w1.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
module J7W1
|
4
|
-
autoload :Configuration,
|
5
|
-
autoload :Util,
|
6
|
-
autoload :Version,
|
7
|
-
autoload :ActiveRecordExt,
|
8
|
-
autoload :MockPushClient,
|
9
|
-
autoload :SNSPushClient,
|
4
|
+
autoload :Configuration, 'j7w1/configuration'
|
5
|
+
autoload :Util, 'j7w1/util'
|
6
|
+
autoload :Version, 'j7w1/version'
|
7
|
+
autoload :ActiveRecordExt, 'j7w1/active_record_ext'
|
8
|
+
autoload :MockPushClient, 'j7w1/mock_push_client'
|
9
|
+
autoload :SNSPushClient, 'j7w1/sns_push_client'
|
10
|
+
autoload :PushRefused, 'j7w1/exceptions'
|
10
11
|
|
11
12
|
ActiveRecord::Base.__send__(:include, ActiveRecordExt) if defined? ActiveRecord::Base
|
12
13
|
|
data/lib/j7w1/sns_push_client.rb
CHANGED
@@ -4,6 +4,8 @@ module J7W1
|
|
4
4
|
AWS::SNS.new configuration.account
|
5
5
|
end
|
6
6
|
|
7
|
+
APNS_MAX_MESSAGE_SIZE = 40
|
8
|
+
|
7
9
|
APS_TABLE = {
|
8
10
|
message: :alert,
|
9
11
|
badge: :badge,
|
@@ -14,6 +16,7 @@ module J7W1
|
|
14
16
|
message: :message,
|
15
17
|
badge: :badge,
|
16
18
|
sound: :sound,
|
19
|
+
data: :data,
|
17
20
|
}.freeze
|
18
21
|
|
19
22
|
def create_ios_application(name, certs, private_key, options)
|
@@ -86,6 +89,7 @@ module J7W1
|
|
86
89
|
message = options[:message]
|
87
90
|
badge = options[:badge]
|
88
91
|
sound = options[:sound]
|
92
|
+
data = options[:data]
|
89
93
|
sns_configuration = options[:sns_configuration]
|
90
94
|
sns_client = options[:sns_client]
|
91
95
|
|
@@ -94,7 +98,7 @@ module J7W1
|
|
94
98
|
message_value.merge!(badge: badge) unless badge.blank?
|
95
99
|
message_value.merge!(sound: sound) unless sound.blank?
|
96
100
|
|
97
|
-
payload = payload_for(message_value, platform)
|
101
|
+
payload = payload_for(message_value, data, platform)
|
98
102
|
|
99
103
|
sns_client ||= create_sns_client(sns_configuration || J7W1.configuration)
|
100
104
|
client = sns_client.client
|
@@ -112,23 +116,33 @@ module J7W1
|
|
112
116
|
end
|
113
117
|
|
114
118
|
private
|
115
|
-
def payload_for(message_value, platform)
|
119
|
+
def payload_for(message_value, data, platform)
|
116
120
|
case platform.to_sym
|
117
121
|
when :ios
|
118
|
-
ios_payload_for(message_value)
|
122
|
+
ios_payload_for(message_value, data)
|
119
123
|
when :android
|
120
|
-
android_payload_for(message_value)
|
124
|
+
android_payload_for(message_value, data)
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
124
|
-
def ios_payload_for(message_value)
|
128
|
+
def ios_payload_for(message_value, data)
|
125
129
|
prefix = J7W1.configuration.ios_endpoint.sandbox? ?
|
126
130
|
:APNS_SANDBOX : :APNS
|
127
131
|
|
128
|
-
|
132
|
+
if message_value[:message] && message_value[:message] > APNS_MAX_MESSAGE_SIZE
|
133
|
+
message_value[:message] = message_value[:message][0...(APNS_MAX_MESSAGE_SIZE - 3)] + '...'
|
134
|
+
end
|
135
|
+
|
136
|
+
content = {
|
137
|
+
aps: message_content_with_table(message_value, APS_TABLE),
|
138
|
+
}
|
139
|
+
content.merge! data: data if data
|
140
|
+
|
141
|
+
{prefix => content.to_json}
|
129
142
|
end
|
130
143
|
|
131
|
-
def android_payload_for(message_value)
|
144
|
+
def android_payload_for(message_value, data)
|
145
|
+
message_value.merge!(data: data)
|
132
146
|
{
|
133
147
|
GCM: {
|
134
148
|
data: message_content_with_table(message_value, ANDROID_TABLE)
|
data/lib/j7w1/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- condor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|