Class: ApnsSimple::Notification
- Inherits:
-
Object
- Object
- ApnsSimple::Notification
- Defined in:
- lib/apns_simple/notification.rb
Constant Summary collapse
- PAYLOAD_MAX_BYTESIZE =
2048
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(options, custom_payload = {}) ⇒ Notification
constructor
A new instance of Notification.
Constructor Details
#initialize(options, custom_payload = {}) ⇒ Notification
Returns a new instance of Notification.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/apns_simple/notification.rb', line 11 def initialize(, custom_payload = {}) token = .fetch(:token) alert = [:alert] badge = [:badge] sound = [:sound] content_available = [:content_available] payload_hash = { aps: {} } payload_hash[:aps][:alert] = alert if alert payload_hash[:aps][:badge] = badge if badge payload_hash[:aps][:sound] = sound if sound payload_hash[:aps]['content-available'] = 1 if content_available payload_hash.merge! custom_payload token_item = pack_token_item(token) payload_item = pack_payload_item(payload_hash) frame = compose_frame(token_item, payload_item) @payload = pack_frame(frame) end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
9 10 11 |
# File 'lib/apns_simple/notification.rb', line 9 def error @error end |
#error_code ⇒ Object
Returns the value of attribute error_code.
9 10 11 |
# File 'lib/apns_simple/notification.rb', line 9 def error_code @error_code end |
#error_message ⇒ Object
Returns the value of attribute error_message.
9 10 11 |
# File 'lib/apns_simple/notification.rb', line 9 def @error_message end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
8 9 10 |
# File 'lib/apns_simple/notification.rb', line 8 def payload @payload end |