Class: BMO::GCM::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bmo/gcm/client.rb

Overview

GCM Client Class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway_url, api_key) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/bmo/gcm/client.rb', line 7

def initialize(gateway_url, api_key)
  @gateway_url = gateway_url
  @api_key     = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/bmo/gcm/client.rb', line 5

def api_key
  @api_key
end

#gateway_urlObject (readonly)

Returns the value of attribute gateway_url.



5
6
7
# File 'lib/bmo/gcm/client.rb', line 5

def gateway_url
  @gateway_url
end

Instance Method Details

#send_notification(notification) ⇒ Object

Parameters:

  • notification (Notification)

    the notification to send to Google



14
15
16
17
18
19
# File 'lib/bmo/gcm/client.rb', line 14

def send_notification(notification)
  connection = GCM::Connection.new(gateway_url, api_key)
  connection.connect do |request|
    request.body = notification.to_package
  end
end