Class: ApplePush::Notification
- Inherits:
-
Object
- Object
- ApplePush::Notification
- Defined in:
- lib/apple-push/notification.rb
Instance Attribute Summary collapse
-
#alert ⇒ Object
Returns the value of attribute alert.
-
#badge ⇒ Object
Returns the value of attribute badge.
-
#device_token ⇒ Object
Returns the value of attribute device_token.
-
#other ⇒ Object
Returns the value of attribute other.
-
#sound ⇒ Object
Returns the value of attribute sound.
Instance Method Summary collapse
-
#initialize(device_token, message) ⇒ Notification
constructor
A new instance of Notification.
- #to_s ⇒ Object
Constructor Details
#initialize(device_token, message) ⇒ Notification
Returns a new instance of Notification.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apple-push/notification.rb', line 5 def initialize(device_token, ) if device_token self.device_token = device_token else raise "Invalid device token" end if .is_a?(Hash) self.alert = [:alert] self.badge = [:badge] self.sound = [:sound] self.other = [:other] elsif .is_a?(String) self.alert = else raise "Notification message needs to be either a hash or a string" end end |
Instance Attribute Details
#alert ⇒ Object
Returns the value of attribute alert.
3 4 5 |
# File 'lib/apple-push/notification.rb', line 3 def alert @alert end |
#badge ⇒ Object
Returns the value of attribute badge.
3 4 5 |
# File 'lib/apple-push/notification.rb', line 3 def badge @badge end |
#device_token ⇒ Object
Returns the value of attribute device_token.
3 4 5 |
# File 'lib/apple-push/notification.rb', line 3 def device_token @device_token end |
#other ⇒ Object
Returns the value of attribute other.
3 4 5 |
# File 'lib/apple-push/notification.rb', line 3 def other @other end |
#sound ⇒ Object
Returns the value of attribute sound.
3 4 5 |
# File 'lib/apple-push/notification.rb', line 3 def sound @sound end |
Instance Method Details
#to_s ⇒ Object
31 32 33 34 35 |
# File 'lib/apple-push/notification.rb', line 31 def to_s dt = self.device_token pl = self.payload [0, 0, dt.size, dt, 0, pl.size, pl].pack("ccca*cca*") end |