Module: Pushlayer
- Defined in:
- lib/pushlayer.rb,
lib/pushlayer/version.rb
Constant Summary collapse
- VERSION =
'0.9.1'
- @@api_id =
''
- @@api_key =
''
Class Method Summary collapse
- .api_id=(id) ⇒ Object
- .api_key=(key) ⇒ Object
-
.post_notification(device_token, alert_body, opts = {}) ⇒ Object
Send a push notification.
Class Method Details
.api_id=(id) ⇒ Object
13 14 15 |
# File 'lib/pushlayer.rb', line 13 def self.api_id=(id) @@api_id = id end |
.api_key=(key) ⇒ Object
17 18 19 |
# File 'lib/pushlayer.rb', line 17 def self.api_key=(key) @@api_key = key end |
.post_notification(device_token, alert_body, opts = {}) ⇒ Object
Send a push notification
Upon success, a Ruby hash object will be returned representing the notification object sent.
Under the hood, Pushlayer is using rest_client to communicate with the service. Be sure to familiarize yourself with rest_client’s behavior in terms of exceptions:
45 46 47 48 49 50 |
# File 'lib/pushlayer.rb', line 45 def self.post_notification(device_token, alert_body, opts={}) params = { device_token: device_token, alert_body: alert_body }.merge opts headers = { accept: :json, content_type: :json, user_agent: user_agent } RestClient.post endpoint, MultiJson.dump(params), headers end |