Module: ApplePush

Defined in:
lib/apple-push.rb,
lib/apple-push/version.rb,
lib/apple-push/notification.rb

Defined Under Namespace

Classes: Notification

Constant Summary collapse

Version =
VERSION = '1.0.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hostObject

Returns the value of attribute host.



15
16
17
# File 'lib/apple-push.rb', line 15

def host
  @host
end

.portObject

Returns the value of attribute port.



16
17
18
# File 'lib/apple-push.rb', line 16

def port
  @port
end

Class Method Details

.send_notification(apns_pem, apns_token, message = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/apple-push.rb', line 19

def self.send_notification(apns_pem, apns_token, message = {})
  connection(apns_pem) do |ssl|
    notification = ApplePush::Notification.new(apns_token, message)
    puts "#{Time.now} [#{host}:#{port}] Device: #{notification.device_token.unpack('H*')} sending #{message.inspect}"
    ssl.write(notification.to_s)
  end
end