Class: Pushofy::ApplePush
- Inherits:
-
Object
- Object
- Pushofy::ApplePush
- Defined in:
- lib/pushofy/applepush.rb
Instance Method Summary collapse
- #feedback ⇒ Object
-
#initialize(payload_hash, settings) ⇒ ApplePush
constructor
A new instance of ApplePush.
- #push ⇒ Object
Constructor Details
#initialize(payload_hash, settings) ⇒ ApplePush
Returns a new instance of ApplePush.
9 10 11 12 13 |
# File 'lib/pushofy/applepush.rb', line 9 def initialize(payload_hash, settings) @deviceTokenHex = payload_hash["device"] @payload_hash = payload_hash.delete('device') @settings = settings end |
Instance Method Details
#feedback ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pushofy/applepush.rb', line 27 def feedback host = 'feedback.sandbox.push.apple.com' path = Dir.pwd + '/app/controllers/CertificateName.pem' ssl_client = Pushofy::ConnectionToAppleServer::ssl_connect(host, 2196, path) ssl_client.connect apns_feedback = [] while = ssl_client.gets , _token_size, token = .unpack('N1n1H*') apns_feedback << [Time.at(), token] end ssl.close sock.close end |
#push ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pushofy/applepush.rb', line 14 def push path = @cert_name ssl_client = Pushofy::ConnectionToAppleServer::ssl_connect(@settings[:host], @settings[:port], @settings[:password], @settings[:cert]) ssl_client.connect device = [@deviceTokenHex] device_token_binary = device.pack('H*') pt = device_token_binary pm = @payload_hash.to_json = [0, 0, 32, pt, 0, pm.size, pm].pack('ccca*cca*') ssl_client.write() ssl_client.flush end |