Class: RubyPushNotifications::GCM::GCMPusher

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

Overview

This class is responsible for sending notifications to the GCM service.

Author:

  • Carlos Alonso

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ GCMPusher

Initializes the GCMPusher

Parameters:


14
15
16
# File 'lib/ruby-push-notifications/gcm/gcm_pusher.rb', line 14

def initialize(key)
  @key = key
end

Instance Method Details

#push(notifications) ⇒ Object

Actually pushes the given notifications. Assigns every notification an array with the result of each individual notification.

Parameters:

  • notifications (Array)

    . Array of GCMNotification to send.


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

def push(notifications)
  notifications.each do |notif|
    notif.results = GCMConnection.post notif.as_gcm_json, @key
  end
end