class Crusade::APNS::NotificationEncoder

Attributes

configuration[RW]

Public Class Methods

new(configuration) click to toggle source
# File lib/crusade/apns/notification_encoder.rb, line 4
def initialize configuration
  self.configuration = configuration
end

Public Instance Methods

encode(notification) click to toggle source
# File lib/crusade/apns/notification_encoder.rb, line 8
def encode notification
  to_binary(notification)
end

Private Instance Methods

expiry() click to toggle source
# File lib/crusade/apns/notification_encoder.rb, line 29
def expiry
  86400
end
id_for_pack() click to toggle source
# File lib/crusade/apns/notification_encoder.rb, line 33
def id_for_pack
  0
end
to_binary(notification) click to toggle source
# File lib/crusade/apns/notification_encoder.rb, line 16
def to_binary(notification)
  [
     1,
     id_for_pack,
     expiry,
     0,
     32,
     notification.device_token,
     notification.json_size,
     notification.to_json
  ].pack("cNNccH*na*")
end