Class: Pushofy::AndroidPush
- Inherits:
-
Object
- Object
- Pushofy::AndroidPush
- Defined in:
- lib/pushofy/androidpush.rb
Instance Method Summary collapse
-
#initialize(body, settings) ⇒ AndroidPush
constructor
A new instance of AndroidPush.
- #push ⇒ Object
Constructor Details
#initialize(body, settings) ⇒ AndroidPush
Returns a new instance of AndroidPush.
8 9 10 11 |
# File 'lib/pushofy/androidpush.rb', line 8 def initialize(body,settings) @settings = settings @body = body end |
Instance Method Details
#push ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pushofy/androidpush.rb', line 12 def push uri = URI('https://android.googleapis.com/gcm/send') auth_key = "key=#{@settings[:api_key]}" headers = { 'Content-Type' => 'application/json', 'Authorization' => auth_key } http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.post(uri.path, @body.to_json, headers) end |