Class: Apns::Persistent::FeedbackClient
- Inherits:
-
Client
- Object
- Client
- Apns::Persistent::FeedbackClient
show all
- Defined in:
- lib/apns/persistent/feedback_client.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Client
#initialize
Class Method Details
.gateway_uri(sandbox) ⇒ Object
33
34
35
|
# File 'lib/apns/persistent/feedback_client.rb', line 33
def self.gateway_uri(sandbox)
sandbox ? "apn://feedback.sandbox.push.apple.com:2196" : "apn://feedback.push.apple.com:2196"
end
|
.unregistered_device_tokens_once(certificate:, sandbox: true) ⇒ Object
12
13
14
|
# File 'lib/apns/persistent/feedback_client.rb', line 12
def self.unregistered_device_tokens_once(certificate: , sandbox: true)
FeedbackClient.unregistered_devices_once(certificate: certificate, sandbox: sandbox).collect { |device| device[:token] }
end
|
.unregistered_devices_once(certificate:, sandbox: true) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/apns/persistent/feedback_client.rb', line 4
def self.unregistered_devices_once(certificate: , sandbox: true)
client = Apns::Persistent::FeedbackClient.new(certificate: certificate, sandbox: sandbox)
client.open
devices = client.unregistered_devices
client.close
devices
end
|
Instance Method Details
#unregistered_device_tokens ⇒ Object
29
30
31
|
# File 'lib/apns/persistent/feedback_client.rb', line 29
def unregistered_device_tokens
unregistered_devices.collect { |device| device[:token] }
end
|
#unregistered_devices ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/apns/persistent/feedback_client.rb', line 16
def unregistered_devices
raise 'please open' if closed?
devices = []
while line = @connection.read(38)
feedback = line.unpack('N1n1H140')
timestamp = feedback[0]
token = feedback[2].scan(/.{0,8}/).join(' ').strip
devices << {token: token, timestamp: timestamp} if token && timestamp
end
devices
end
|