apns_simple 0.1.3 → 0.2.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: af84d5bd9fa18a32957e9eb0008b56ed89a9bda3
4
- data.tar.gz: 7a119bf86cc8bb29c224e85f0f2dd20432914491
3
+ metadata.gz: 54dbbd173f8e1b261c87848e4ff13cf6e2d7bafc
4
+ data.tar.gz: b0b353941c8e2b80fc9c2c815d7a589b446d5341
5
5
  SHA512:
6
- metadata.gz: 0256e15adc51a8feda1f0eef23bd6d861da6b13badf79c4c5bafeac68970814304b68bafb9488914dff331ad1f01cfeaa7ca919ad3843b177aaa565d212dcd2c
7
- data.tar.gz: a8dd256f9aaeae21b8bb9d380856ff81a7f8793ffbe5bfaef82abe7d5131b226f65214c7e5a0d52a200af740db3e768f32cd851ed75c9f0166937300b68f1da7
6
+ metadata.gz: 3346fdb4e641301f1f0dcfdd2303f9b7cebafb86682813be9f581fe278fdfad6c83b47153d4fd132a0492b377d6daaab7b75e94b0b4ff1c72c41fd07adc3ff06
7
+ data.tar.gz: bde5768c3c3436d986182947ad0fe23f518b95583e89d69f7beeb57b4e94a1d5b9f15bed0c129122f18a05fa7c297fbef8dfa3dce29d0aee36b70059d1dcf7ed
@@ -6,6 +6,21 @@ module ApnsSimple
6
6
 
7
7
  attr_reader :certificate, :passphrase, :host, :port
8
8
 
9
+ COMMAND = 8
10
+ CODES = {
11
+ 0 => 'No errors encountered',
12
+ 1 => 'Processing error',
13
+ 2 => 'Missing device token',
14
+ 3 => 'Missing topic',
15
+ 4 => 'Missing payload',
16
+ 5 => 'Invalid token size',
17
+ 6 => 'Invalid topic size',
18
+ 7 => 'Invalid payload size',
19
+ 8 => 'Invalid token',
20
+ 10 => 'Shutdown',
21
+ 255 => 'Unknown error'
22
+ }
23
+
9
24
  def initialize(options)
10
25
  @certificate = options.fetch(:certificate)
11
26
  @passphrase = options[:passphrase] || ''
@@ -26,8 +41,8 @@ module ApnsSimple
26
41
  ssl.flush
27
42
 
28
43
  if IO.select([ssl], nil, nil, 1) && error = ssl.read(6)
29
- _command, status, _index = error.unpack("ccN")
30
- notification.error = status
44
+ command, status, _index = error.unpack("ccN")
45
+ notification.error = command == COMMAND ? "#{status}: #{CODES[status]}" : "Unknown command received from APNS server: #{command}"
31
46
  end
32
47
  ensure
33
48
  ssl.close if ssl
@@ -1,3 +1,3 @@
1
1
  module ApnsSimple
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Voronkov