Class: BMO::APNS::Notification
- Inherits:
-
Object
- Object
- BMO::APNS::Notification
- Defined in:
- lib/bmo/apns/notification.rb
Overview
The Notification Class handles all the packaging logic
Defined Under Namespace
Classes: DeviceToken, Payload
Instance Attribute Summary collapse
-
#device_token ⇒ Object
readonly
Returns the value of attribute device_token.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(device_token, payload, options = {}) ⇒ Notification
constructor
A new instance of Notification.
- #to_package ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(device_token, payload, options = {}) ⇒ Notification
Returns a new instance of Notification.
10 11 12 13 |
# File 'lib/bmo/apns/notification.rb', line 10 def initialize(device_token, payload, = {}) @device_token = DeviceToken.new(device_token) @payload = Payload.new(payload, ) end |
Instance Attribute Details
#device_token ⇒ Object (readonly)
Returns the value of attribute device_token.
8 9 10 |
# File 'lib/bmo/apns/notification.rb', line 8 def device_token @device_token end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
8 9 10 |
# File 'lib/bmo/apns/notification.rb', line 8 def payload @payload end |
Instance Method Details
#to_package ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/bmo/apns/notification.rb', line 15 def to_package payload_packaged = payload.to_package device_token_packaged = device_token.to_package data = [ device_token_packaged, payload_packaged ].join [2, data.bytes.count, data].pack('cNa*') end |
#validate! ⇒ Object
25 26 27 28 |
# File 'lib/bmo/apns/notification.rb', line 25 def validate! device_token.validate! payload.validate! end |