matchbox20 0.3.3 → 0.3.4
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.
- data/lib/matchbox20/version.rb +1 -1
- data/lib/matchbox20.rb +9 -2
- metadata +2 -2
data/lib/matchbox20/version.rb
CHANGED
data/lib/matchbox20.rb
CHANGED
|
@@ -48,6 +48,10 @@ module Matchbox20
|
|
|
48
48
|
|
|
49
49
|
cert = self.apn_production? ? "apn_production.pem" : "apn_development.pem"
|
|
50
50
|
|
|
51
|
+
if respond_to?(:cert_file_name)
|
|
52
|
+
cert = cert_file_name
|
|
53
|
+
end
|
|
54
|
+
|
|
51
55
|
path = File.join(File.expand_path(Rails.root.to_s), "config", "certs", cert)
|
|
52
56
|
@@apn_cert = File.exists?(path) ? File.read(path) : nil
|
|
53
57
|
|
|
@@ -104,7 +108,7 @@ module Matchbox20
|
|
|
104
108
|
|
|
105
109
|
|
|
106
110
|
protected
|
|
107
|
-
|
|
111
|
+
|
|
108
112
|
def self.is_connected_to_gateway?
|
|
109
113
|
@@s && @@ssl
|
|
110
114
|
end
|
|
@@ -121,14 +125,16 @@ module Matchbox20
|
|
|
121
125
|
|
|
122
126
|
def apn_message_for_sending options
|
|
123
127
|
json = Matchbox20::apple_json_array options
|
|
128
|
+
|
|
124
129
|
message = "\0\0 #{self.device_token_hexa}\0#{json.length.chr}#{json}"
|
|
130
|
+
|
|
125
131
|
raise "The maximum size allowed for a notification payload is 256 bytes." if message.size.to_i > 256
|
|
126
132
|
message
|
|
127
133
|
end
|
|
128
134
|
|
|
129
135
|
def device_token_hexa
|
|
130
136
|
# Use `device_token` as the method to get the token from
|
|
131
|
-
# unless it is
|
|
137
|
+
# unless it is overridden from acts_as_pushable
|
|
132
138
|
|
|
133
139
|
apn_token_field = "device_token"
|
|
134
140
|
if respond_to?(:acts_as_push_options)
|
|
@@ -137,6 +143,7 @@ module Matchbox20
|
|
|
137
143
|
|
|
138
144
|
token = send(apn_token_field.to_sym)
|
|
139
145
|
raise "Cannot send push notification without device token" if !token || token.empty?
|
|
146
|
+
|
|
140
147
|
[token.delete(' ')].pack('H*')
|
|
141
148
|
end
|
|
142
149
|
|