Class: RubyPushNotifications::GCM::GCMNotification

Inherits:
Object
  • Object
show all
Includes:
NotificationResultsManager
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

Attributes included from NotificationResultsManager

#results

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.



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

def initialize(registration_ids, data)
  @registration_ids = registration_ids
  @data = data
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:



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

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