j7w1 0.0.17 → 0.0.18

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: 015073b124bf0e8f9a4a37f2c553c1238be903ca
4
- data.tar.gz: 6e1cd196723d5d748a530d0c6db2c05fc47e005e
3
+ metadata.gz: c1a71b5172329b1a6d8ee0fb802550a281603a64
4
+ data.tar.gz: b1ab7f15f14a6c33192ae52f1a49264e2d4ddb91
5
5
  SHA512:
6
- metadata.gz: 2f110d6d06ec461d4055d8eaac0c6863e7d0f4f3ba4a1911b11c87a1dddf2b7562cae90293c3fb40548b98c7fcd11bf148c24819bfd0fab6d4634c597c83082e
7
- data.tar.gz: 6ec532b203caa78acc6d65dda12c85f1406783cc59054f5d932debbf42f32a57762286a4d3b745d7c63c9033b93769bccf86ed94696c7e8f641ed99ebd0f68e6
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, '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'
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
 
@@ -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
- {prefix => {aps: message_content_with_table(message_value, APS_TABLE)}.to_json}
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
@@ -1,3 +1,3 @@
1
1
  module J7W1
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
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.17
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-12 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk