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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e9d10c4b40b0eec209b3df3a4e4efd902d346e0
4
- data.tar.gz: 545ce5885e94bab878faeb1ff11c030d89986fc7
3
+ metadata.gz: b21f5930a8df2406544a6c54a4c054356466034b
4
+ data.tar.gz: 4da2296c3c44a45f5aa639e576f918d98d688381
5
5
  SHA512:
6
- metadata.gz: 9f923b01bae484adf92cc5b9919f4c1b9857f8db414a32ec8558cdc6e2fbb222b9cf215a3514fa546c9b8636abb43e46c92d4dea4ff9704b82c6647064af02dc
7
- data.tar.gz: 71bbe0c86313f74c58f6ce27a500a06dd397f1549ca52f065564a13461eddbf2de4c23e7f5eb674a5f3f43b20f562c2b4b692b153a1617454cd6f0401b57aaef
6
+ metadata.gz: 86434817e68afae4e816270284168fcd98364bd0181aa37e2e9722e6e5a50f383d7997244a9f1eeb768fc81b27894350206d75473b813dff1c76564f95c22fba
7
+ data.tar.gz: 5a2111b22dc30fd13d39f95b1de1a5b8429cc5382c13d100492c918d3b3715a7040c670d913888d0a7dcf5d6208e741dde209324bfa75ac1477d1e7fa34d7334
@@ -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
- result = IO.select([ssl], nil, nil, TIMEOUT)
53
+ ready = IO.select([ssl], [], [], TIMEOUT)
54
54
 
55
- unless result
56
- notification.error = "No response from APNS server received in #{TIMEOUT} seconds. Exit by timeout."
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
- readables = result.first # Array of readable sockets.
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
- command, status, _index = error.unpack("ccN")
65
- notification.error = command == COMMAND ? "#{status}: #{CODES[status]}" : "Unknown command received from APNS server: #{command}"
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)
@@ -1,3 +1,3 @@
1
1
  module ApnsSimple
2
- VERSION = '0.9.0'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apns_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Voronkov