Class: EventMachine::APN::Notification
- Inherits:
-
Object
- Object
- EventMachine::APN::Notification
- Defined in:
- lib/em-apn/notification.rb
Defined Under Namespace
Classes: PayloadTooLarge
Constant Summary collapse
- PAYLOAD_MAX_BYTES =
256
Instance Attribute Summary collapse
-
#expiry ⇒ Object
Returns the value of attribute expiry.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #alert ⇒ Object
- #data ⇒ Object
-
#initialize(token, aps = {}, custom = {}, options = {}) ⇒ Notification
constructor
A new instance of Notification.
- #payload ⇒ Object
Constructor Details
#initialize(token, aps = {}, custom = {}, options = {}) ⇒ Notification
Returns a new instance of Notification.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/em-apn/notification.rb', line 12 def initialize(token, aps = {}, custom = {}, = {}) raise "Bad push token: #{token}" if token.nil? || (token.length != 64) @token = token @aps = aps @custom = custom self.identifier = [:identifier] if [:identifier] self.expiry = [:expiry] if [:expiry] end |
Instance Attribute Details
#expiry ⇒ Object
Returns the value of attribute expiry.
10 11 12 |
# File 'lib/em-apn/notification.rb', line 10 def expiry @expiry end |
#identifier ⇒ Object
Returns the value of attribute identifier.
10 11 12 |
# File 'lib/em-apn/notification.rb', line 10 def identifier @identifier end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/em-apn/notification.rb', line 9 def token @token end |
Instance Method Details
#alert ⇒ Object
35 36 37 |
# File 'lib/em-apn/notification.rb', line 35 def alert @aps["alert"][0..49] if @aps.include?("alert") end |
#data ⇒ Object
27 28 29 |
# File 'lib/em-apn/notification.rb', line 27 def data @data ||= build_data end |
#payload ⇒ Object
23 24 25 |
# File 'lib/em-apn/notification.rb', line 23 def payload @payload ||= build_payload end |