Class: Pling::APN::Feedback
- Inherits:
-
Object
- Object
- Pling::APN::Feedback
- Includes:
- Configurable
- Defined in:
- lib/pling/apn/feedback.rb
Overview
Instances of this class can be used to retrieve device identifiers that have been marked invalid. This should be done on a regular basis since Apple will ban you if you continue to send push notifications to invalid devices.
The only operation supported by instances of this class is #get. The method simply returns a list of the identifieres that have been marked invalid since you last called this method.
Instance Method Summary collapse
-
#get ⇒ Array<String>
Retrieves all device identifiers that have been marked invalid since the method has been called last.
-
#initialize(configuration) ⇒ Feedback
constructor
Creates a new instance of this class and establishes a connection to Apple’s Push Notification Service, retrieves a list of invalid device identifiers and then closes the connection, since Apple closes it on their side.
Constructor Details
#initialize(configuration) ⇒ Feedback
Creates a new instance of this class and establishes a connection to Apple’s Push Notification Service, retrieves a list of invalid device identifiers and then closes the connection, since Apple closes it on their side.
For testing purposes, you should use Apple’s sandbox feedback service feedback.sandbox.push.apple.com. In order to do this, you have to specify the optional :host parameter when creating instances of this class.
50 51 52 |
# File 'lib/pling/apn/feedback.rb', line 50 def initialize(configuration) setup_configuration(configuration, :require => :certificate) end |
Instance Method Details
#get ⇒ Array<String>
Retrieves all device identifiers that have been marked invalid since the method has been called last.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pling/apn/feedback.rb', line 60 def get tokens = [] while line = connection.gets _, length = line.unpack("Nn") break if length.nil? tokens << line.unpack("x6H#{length << 1}").first end connection.close tokens end |