Class: APNS::Notification
- Inherits:
-
Object
- Object
- APNS::Notification
- Includes:
- ActiveModel::Model
- Defined in:
- lib/mercurius/apns/notification.rb
Constant Summary collapse
- MAX_PAYLOAD_BYTES =
2048
Instance Attribute Summary collapse
-
#alert ⇒ Object
Returns the value of attribute alert.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#badge ⇒ Object
Returns the value of attribute badge.
-
#content_available ⇒ Object
Returns the value of attribute content_available.
-
#other ⇒ Object
Returns the value of attribute other.
-
#sound ⇒ Object
Returns the value of attribute sound.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(attributes = {}) ⇒ Notification
constructor
A new instance of Notification.
- #pack(device_token) ⇒ Object
- #payload ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Notification
Returns a new instance of Notification.
12 13 14 15 |
# File 'lib/mercurius/apns/notification.rb', line 12 def initialize(attributes = {}) @attributes = attributes super end |
Instance Attribute Details
#alert ⇒ Object
Returns the value of attribute alert.
7 8 9 |
# File 'lib/mercurius/apns/notification.rb', line 7 def alert @alert end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/mercurius/apns/notification.rb', line 8 def attributes @attributes end |
#badge ⇒ Object
Returns the value of attribute badge.
7 8 9 |
# File 'lib/mercurius/apns/notification.rb', line 7 def badge @badge end |
#content_available ⇒ Object
Returns the value of attribute content_available.
7 8 9 |
# File 'lib/mercurius/apns/notification.rb', line 7 def content_available @content_available end |
#other ⇒ Object
Returns the value of attribute other.
7 8 9 |
# File 'lib/mercurius/apns/notification.rb', line 7 def other @other end |
#sound ⇒ Object
Returns the value of attribute sound.
7 8 9 |
# File 'lib/mercurius/apns/notification.rb', line 7 def sound @sound end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/mercurius/apns/notification.rb', line 35 def ==(other) attributes == other.attributes end |
#pack(device_token) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/mercurius/apns/notification.rb', line 27 def pack(device_token) data = [ package_device_token(device_token), packaged_payload ].compact.join [2, data.bytes.count, data].pack 'cNa*' end |
#payload ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mercurius/apns/notification.rb', line 17 def payload { 'alert' => alert, 'badge' => badge, 'sound' => sound, 'other' => other, 'content-available' => content_available }.compact end |