Class: RubyPushNotifications::GCM::GCMNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-push-notifications/gcm/gcm_notification.rb

Overview

Encapsulates a GCM Notification. By default only Required fields are set. (developer.android.com/google/gcm/server-ref.html#send-downstream)

Author:

  • Carlos Alonso

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registration_ids, data) ⇒ GCMNotification

Initializes the notification

Parameters:

  • . (Array)

    Array with the receiver’s GCM registration ids.

  • . (Hash)

    Payload to send.



18
19
20
21
# File 'lib/ruby-push-notifications/gcm/gcm_notification.rb', line 18

def initialize(registration_ids, data)
  @registration_ids = registration_ids
  @data = data
end

Instance Attribute Details

#resultsArray

Returns . Array with the results from sending this notification.

Returns:

  • (Array)

    . Array with the results from sending this notification



12
13
14
# File 'lib/ruby-push-notifications/gcm/gcm_notification.rb', line 12

def results
  @results
end

Instance Method Details

#as_gcm_jsonString

Returns . The GCM’s JSON format for the payload to send. (developer.android.com/google/gcm/server-ref.html#send-downstream).

Returns:



25
26
27
28
29
30
# File 'lib/ruby-push-notifications/gcm/gcm_notification.rb', line 25

def as_gcm_json
  JSON.dump(
    registration_ids: @registration_ids,
    data: @data
  )
end