apns_simple 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apns_simple/client.rb +14 -8
- data/lib/apns_simple/notification.rb +1 -1
- data/lib/apns_simple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21f5930a8df2406544a6c54a4c054356466034b
|
4
|
+
data.tar.gz: 4da2296c3c44a45f5aa639e576f918d98d688381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86434817e68afae4e816270284168fcd98364bd0181aa37e2e9722e6e5a50f383d7997244a9f1eeb768fc81b27894350206d75473b813dff1c76564f95c22fba
|
7
|
+
data.tar.gz: 5a2111b22dc30fd13d39f95b1de1a5b8429cc5382c13d100492c918d3b3715a7040c670d913888d0a7dcf5d6208e741dde209324bfa75ac1477d1e7fa34d7334
|
data/lib/apns_simple/client.rb
CHANGED
@@ -46,23 +46,29 @@ module ApnsSimple
|
|
46
46
|
begin
|
47
47
|
sock = TCPSocket.new(host, port)
|
48
48
|
ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
|
49
|
+
ssl.sync = true
|
49
50
|
ssl.connect
|
50
51
|
ssl.write(notification.payload)
|
51
|
-
ssl.flush
|
52
52
|
|
53
|
-
|
53
|
+
ready = IO.select([ssl], [], [], TIMEOUT)
|
54
54
|
|
55
|
-
unless
|
56
|
-
notification.error =
|
55
|
+
unless ready
|
56
|
+
notification.error = true
|
57
|
+
notification.error_message = "No response from APNS server received in #{TIMEOUT} seconds. Exit by timeout."
|
57
58
|
return
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
-
readable_ssl_socket = readables.first # Find one and only socket we are watching.
|
61
|
+
readable_ssl_socket = ready.first.first
|
62
62
|
|
63
63
|
if (error = readable_ssl_socket.read(6))
|
64
|
-
|
65
|
-
|
64
|
+
notification.error = true
|
65
|
+
command, code, _index = error.unpack('ccN')
|
66
|
+
if command == COMMAND
|
67
|
+
notification.error_code = code
|
68
|
+
notification.error_message = "CODE: #{code}, DESCRIPTION: #{CODES[code]}"
|
69
|
+
else
|
70
|
+
notification.error_message = "Unknown command received from APNS server: #{command}"
|
71
|
+
end
|
66
72
|
end
|
67
73
|
ensure
|
68
74
|
ssl.close if ssl
|
@@ -4,7 +4,7 @@ module ApnsSimple
|
|
4
4
|
class Notification
|
5
5
|
|
6
6
|
attr_reader :token, :alert, :badge, :sound, :content_available, :custom_payload
|
7
|
-
attr_accessor :error
|
7
|
+
attr_accessor :error, :error_message, :error_code
|
8
8
|
|
9
9
|
def initialize(options, custom_payload = {})
|
10
10
|
@token = options.fetch(:token)
|
data/lib/apns_simple/version.rb
CHANGED