unipush 0.2.1 → 0.2.2
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 +8 -8
- data/lib/unipush.rb +12 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTE5ZjliMTdlZjFmNWJmMGVhMDBlODA4YTIwZjNjYTlmN2ZlZWQzNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDUwYzFjOWEyNDNmNmNkMzE3N2M1MTczOTBkOTllYWU2OTMxOWI2Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTYwMWZhZDRkYzUwMmUyOTA5MDFkYzQ4OTJkZWY3MWMyYzU1YWIzYTY5NDcy
|
10
|
+
ZDQ0MjYyN2RjM2E0ZDY2ODA4ZjZjMmRhMjhmMzFjOTRmZTRkMDM3NDlhOThi
|
11
|
+
OTZhNzEyYWRlMTZlZGMxODg2MTI1MjAwOWMxYzBhZDJjMGI3ZWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWJhNjRmN2FlNmQzZjAxMTY2Y2Q5YmFjYzY1ODA3OGExYTgwYzZkN2MyMjhk
|
14
|
+
YzVhMDgzMDA0ZTQzZTZiODUzZDc4ZTA3NDJkOTFmNTE4YjliMzAzYjBlNGUy
|
15
|
+
YTQ0NDI1ZTJjMjk3YTQ5MzI4ODYzZmNlNzhmOWU2OGZkMzJjMWY=
|
data/lib/unipush.rb
CHANGED
@@ -35,8 +35,8 @@ module Unipush
|
|
35
35
|
|
36
36
|
@apns_feedback_conn = nil
|
37
37
|
|
38
|
-
@logger = Logger.new(Rails.root.join('log', 'background_custom.log'), shift_age=7, shift_size=1048576)
|
39
|
-
@logger.level = Logger::ERROR
|
38
|
+
# @logger = Logger.new(Rails.root.join('log', 'background_custom.log'), shift_age=7, shift_size=1048576)
|
39
|
+
# @logger.level = Logger::ERROR
|
40
40
|
end
|
41
41
|
|
42
42
|
####################
|
@@ -58,7 +58,7 @@ module Unipush
|
|
58
58
|
# message=[token, message={:text=>"", :badge=>0, :newsstand=>true, :track=>true, :add=>{:param1=>1, :param2=>2}}]
|
59
59
|
##################
|
60
60
|
def send_messages(messages)
|
61
|
-
@logger.info(Time.now.to_s + " -- start sending ios")
|
61
|
+
# @logger.info(Time.now.to_s + " -- start sending ios")
|
62
62
|
begin
|
63
63
|
messages.each_with_index do |m, k|
|
64
64
|
mes = prepare_ios_message(m[0], m[1], k)
|
@@ -68,7 +68,7 @@ module Unipush
|
|
68
68
|
tmp = @ssl.read_nonblock(1)
|
69
69
|
reply = tmp.unpack("CCN")
|
70
70
|
@unsent_messages.push(reply[2])
|
71
|
-
@logger.error(Time.now.to_s + " -- error in message")
|
71
|
+
# @logger.error(Time.now.to_s + " -- error in message")
|
72
72
|
@last_error.push("Could not send message #{reply[2]} width error: "+reply.join(", "))
|
73
73
|
apns_close
|
74
74
|
rescue IO::WaitReadable
|
@@ -77,12 +77,12 @@ module Unipush
|
|
77
77
|
apns_close
|
78
78
|
else
|
79
79
|
apns_close
|
80
|
-
puts(tmp)
|
80
|
+
# puts(tmp)
|
81
81
|
end
|
82
82
|
|
83
83
|
if apns_check_conn
|
84
84
|
@ssl.write(mes)
|
85
|
-
puts(k)
|
85
|
+
# puts(k)
|
86
86
|
#@logger.info(Time.now.to_s + " -- sent one message")
|
87
87
|
end
|
88
88
|
end
|
@@ -108,7 +108,7 @@ module Unipush
|
|
108
108
|
cert_path = @ios_cert_path
|
109
109
|
if FileTest.exist?(cert_path)
|
110
110
|
begin
|
111
|
-
@logger.info(Time.now.to_s + " -- start getting error tokens")
|
111
|
+
# @logger.info(Time.now.to_s + " -- start getting error tokens")
|
112
112
|
certificate = File.read(cert_path)
|
113
113
|
context = OpenSSL::SSL::SSLContext.new
|
114
114
|
context.key = OpenSSL::PKey::RSA.new(certificate)
|
@@ -132,7 +132,7 @@ module Unipush
|
|
132
132
|
ret.push(ff[1])
|
133
133
|
end
|
134
134
|
end
|
135
|
-
@logger.info(Time.now.to_s + " -- got error tokens #{ret.size}")
|
135
|
+
# @logger.info(Time.now.to_s + " -- got error tokens #{ret.size}")
|
136
136
|
ret
|
137
137
|
rescue
|
138
138
|
@last_error.push("Could not get tokens. Exception: #{$!.inspect}")
|
@@ -147,7 +147,7 @@ module Unipush
|
|
147
147
|
private
|
148
148
|
|
149
149
|
def apns_connect
|
150
|
-
@logger.info(Time.now.to_s + " -- connecting to apns")
|
150
|
+
# @logger.info(Time.now.to_s + " -- connecting to apns")
|
151
151
|
cert_path = @ios_cert_path
|
152
152
|
if FileTest.exist?(cert_path)
|
153
153
|
certificate = File.read(cert_path)
|
@@ -224,39 +224,15 @@ module Unipush
|
|
224
224
|
class Android_push
|
225
225
|
attr_accessor :ret, # variable for store the response
|
226
226
|
:gcm_key, # API key for GCM
|
227
|
-
:gcm_url
|
228
|
-
:wp_
|
227
|
+
:gcm_url # GCM URL
|
229
228
|
|
230
229
|
|
231
|
-
#####################
|
232
|
-
# mode = production / development
|
233
|
-
# production - use gateway.push.apple.com and feedback.push.apple.com
|
234
|
-
# development - use sandbox.gateway.push.apple.com and sandbox.feedback.push.apple.com
|
235
|
-
#####################
|
236
|
-
|
237
230
|
def initialize(mode='production')
|
238
|
-
if mode == 'production'
|
239
|
-
@ios_push_url = 'gateway.push.apple.com'
|
240
|
-
@ios_feedback_url = 'feedback.push.apple.com'
|
241
|
-
else
|
242
|
-
@ios_push_url = 'sandbox.gateway.push.apple.com'
|
243
|
-
@ios_feedback_url = 'sandbox.feedback.push.apple.com'
|
244
|
-
end
|
245
|
-
@ios_push_port = '2195'
|
246
|
-
@ios_feedback_port = '2196'
|
247
|
-
@ios_cert_path = ''
|
248
|
-
|
249
|
-
|
250
231
|
@gcm_url = 'https://android.googleapis.com/gcm/send'
|
251
|
-
@gcm_key = nil
|
232
|
+
@gcm_key = nil
|
252
233
|
|
253
234
|
@last_error = []
|
254
235
|
@unsent_messages = []
|
255
|
-
|
256
|
-
@sock = nil
|
257
|
-
@ssl = nil
|
258
|
-
|
259
|
-
@apns_feedback_conn = nil
|
260
236
|
end
|
261
237
|
|
262
238
|
def get_last_error
|
@@ -341,7 +317,7 @@ module Unipush
|
|
341
317
|
end
|
342
318
|
end
|
343
319
|
else
|
344
|
-
@last_error.push("Could not sent packet #{p_num}")
|
320
|
+
@last_error.push("Could not sent packet #{p_num}, code: #{response.code}")
|
345
321
|
end
|
346
322
|
end
|
347
323
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unipush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Kirov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple push notification sender for iOS, Android and Windows phone
|
14
14
|
email: alexey.s.kirov@gmail.com
|