apns_simple 1.0.1 → 1.1.0
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/apns_simple/client.rb +23 -25
- data/lib/apns_simple/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: 51268e8fa7d8d4eef9af6e2dfa9d7c8403cb1518
|
4
|
+
data.tar.gz: dcd4161167952f0638ab5c6125968f94a6d78145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efb6608223756f87afc446e36e58c9070dea16113e730eb6e52ba839d4fd98d0785219dfca2840066def30ef76471ee51269f0ce410444c43f0dc99ce5bf1a9
|
7
|
+
data.tar.gz: afe120a7462aac8ec1a2c69cb90038111ff27d755b5ad486977ba9d487a0e47d07493fe2f7bcc3fac1f7cea49f02f80f7384d53118564000c149b47f210e64af
|
data/lib/apns_simple/client.rb
CHANGED
@@ -46,38 +46,36 @@ module ApnsSimple
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def push(notification)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
ssl.write(notification.payload)
|
49
|
+
notification.error = true
|
50
|
+
sock = TCPSocket.new(host, port)
|
51
|
+
ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
|
52
|
+
ssl.connect
|
53
|
+
ssl.write(notification.payload)
|
54
|
+
ssl.flush
|
56
55
|
|
57
|
-
|
56
|
+
ready = IO.select([ssl], [], [], TIMEOUT)
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
unless ready
|
59
|
+
notification.error_message = "No response from APNS server received in #{TIMEOUT} seconds. Exit by timeout."
|
60
|
+
return
|
61
|
+
end
|
63
62
|
|
64
|
-
|
63
|
+
readable_ssl_socket = ready.first.first
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
notification.error_message = "Unknown command received from APNS server: #{command}"
|
73
|
-
end
|
65
|
+
if (error = readable_ssl_socket.read(ERROR_BYTES_COUNT))
|
66
|
+
command, code, _index = error.unpack('ccN')
|
67
|
+
if command == COMMAND
|
68
|
+
notification.error_code = code
|
69
|
+
notification.error_message = "CODE: #{code}, DESCRIPTION: #{CODES[code]}"
|
74
70
|
else
|
75
|
-
notification.
|
71
|
+
notification.error_message = "Unknown command received from APNS server: #{command}"
|
76
72
|
end
|
77
|
-
|
78
|
-
|
79
|
-
sock.close if sock
|
73
|
+
else
|
74
|
+
notification.error = false
|
80
75
|
end
|
76
|
+
ensure
|
77
|
+
ssl.close if ssl
|
78
|
+
sock.close if sock
|
81
79
|
end
|
82
80
|
|
83
81
|
private
|
data/lib/apns_simple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apns_simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Voronkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|