Skip to content

Instantly share code, notes, and snippets.

@scruffyfox
Created November 3, 2014 14:51
Show Gist options
  • Save scruffyfox/1bce87b751289e98e294 to your computer and use it in GitHub Desktop.
Save scruffyfox/1bce87b751289e98e294 to your computer and use it in GitHub Desktop.
require 'json'
require 'rest'
require 'date'
@notification_token = ""
@pushes = [
''
]
# POST request -> logging in
data = {
'registration_ids' => @pushes,
'data' => {
"type" => "ExternalURI",
"message" => "You have been assigned a Mission nearby!",
'collapse_key' => 'notification',
'sound' => 'tornado-warning-siren.caf',
'link' => 'http://google.com',
"id" => 1
}
}
headers = {
'Authorization' => 'key=' + @notification_token,
'Content-Type' => 'application/json'
}
rest = Rest::Client.new
resp = rest.post("https://android.googleapis.com/gcm/send", {:body => data.to_json, :headers => headers})
puts data.to_json
puts resp.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment