Class: ADCK::Notification

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/adck/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_token, message) ⇒ Notification



7
8
9
10
# File 'lib/adck/notification.rb', line 7

def initialize(device_token, message)
  self.device_token = device_token
  self.message = Message.build(message)
end

Instance Attribute Details

#device_tokenObject

Returns the value of attribute device_token.



4
5
6
# File 'lib/adck/notification.rb', line 4

def device_token
  @device_token
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/adck/notification.rb', line 4

def message
  @message
end

Instance Method Details

#packaged_messageObject



22
23
24
# File 'lib/adck/notification.rb', line 22

def packaged_message
  message.package
end

#packaged_notificationObject



12
13
14
15
16
# File 'lib/adck/notification.rb', line 12

def packaged_notification
  pt = packaged_token
  pm = message.package
  [0, 0, 32, pt, 0, pm.bytesize, pm].pack("ccca*cca*")
end

#packaged_tokenObject



18
19
20
# File 'lib/adck/notification.rb', line 18

def packaged_token
  [device_token.gsub(/[\s|<|>]/,'')].pack('H*')
end