Class: EventMachine::APN::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/em-apn/notification.rb

Defined Under Namespace

Classes: PayloadTooLarge

Constant Summary collapse

PAYLOAD_MAX_BYTES =
256

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  raise "Bad push token: #{token}" if token.nil? || (token.length != 64)

  @token  = token
  @aps    = aps
  @custom = custom

  self.identifier = options[:identifier] if options[:identifier]
  self.expiry = options[:expiry] if options[:expiry]
end

Instance Attribute Details

#expiryObject

Returns the value of attribute expiry.



10
11
12
# File 'lib/em-apn/notification.rb', line 10

def expiry
  @expiry
end

#identifierObject

Returns the value of attribute identifier.



10
11
12
# File 'lib/em-apn/notification.rb', line 10

def identifier
  @identifier
end

#tokenObject (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

#alertObject



35
36
37
# File 'lib/em-apn/notification.rb', line 35

def alert
  @aps["alert"][0..49] if @aps.include?("alert")
end

#dataObject



27
28
29
# File 'lib/em-apn/notification.rb', line 27

def data
  @data ||= build_data
end

#payloadObject



23
24
25
# File 'lib/em-apn/notification.rb', line 23

def payload
  @payload ||= build_payload
end