Class: Push0r::GcmPushMessage
- Inherits:
-
PushMessage
- Object
- PushMessage
- Push0r::GcmPushMessage
- Defined in:
- lib/push0r/GCM/GcmPushMessage.rb
Overview
GcmPushMessage is a PushMessage implementation that encapsulates a single push notification to be sent to a single or multiple users.
Instance Attribute Summary
Attributes inherited from PushMessage
#identifier, #payload, #receiver_token, #time_to_live
Instance Method Summary collapse
-
#initialize(receiver_token, identifier = nil, time_to_live = nil) ⇒ GcmPushMessage
constructor
Returns a new GcmPushMessage instance that encapsulates a single push notification to be sent to a single or multiple users.
Methods inherited from PushMessage
Constructor Details
#initialize(receiver_token, identifier = nil, time_to_live = nil) ⇒ GcmPushMessage
Returns a new GcmPushMessage instance that encapsulates a single push notification to be sent to a single or multiple users.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/push0r/GCM/GcmPushMessage.rb', line 9 def initialize(receiver_token, identifier = nil, time_to_live = nil) if identifier.nil? ## make sure the message has an identifier identifier = Random.rand(2**32) end # for GCM the receiver_token is an array, so make sure we convert a single string to an array containing that string :-) if receiver_token.is_a?(String) receiver_token = [receiver_token] end super(receiver_token, identifier, time_to_live) if time_to_live && time_to_live.to_i >= 0 self.attach({'time_to_live' => time_to_live.to_i}) end end |