Class: MobileNotify::Apns::SimpleNotification

Inherits:
Notification
  • Object
show all
Defined in:
lib/mobile_notify/apns/notification.rb

Constant Summary collapse

EMPTY_BADGE =
0

Constants inherited from Notification

Notification::MAX_PAYLOAD_LENGTH

Instance Method Summary collapse

Methods inherited from Notification

parse, #to_data, #valid?

Constructor Details

#initialize(device_token, badge_value = EMPTY_BADGE, alert = nil, sound = nil, extra = nil) ⇒ SimpleNotification

Returns a new instance of SimpleNotification.



61
62
63
64
65
66
67
68
69
# File 'lib/mobile_notify/apns/notification.rb', line 61

def initialize(device_token, badge_value = EMPTY_BADGE, alert = nil, sound = nil, extra = nil)
  payload = { "aps" => {} }
  payload["aps"]["badge"] = badge_value.to_i
  payload["aps"]["alert"] = alert if alert
  payload["aps"]["sound"] = sound if sound
  payload.update(extra) if extra.is_a?(Hash)

  super(device_token, payload)
end