Question

I have an app that requires push notifications sent to user when a post matching certain criteria is put onto the db. I am using urban airship and HTTParty to make the necessary requests if the conditions are met. My model is as follows:

class Urbanairship
 include HTTParty
 base_uri 'https://go.urbanairship.com'
 headers "Content-Type" => "application/json"
 basic_auth "xxxappkeyxxx", "xxxappsecretxxx"
 default_params :output => 'json'
 format :json

 def self.push(badge, alert_message, token)
  self.post('/api/push/',:body => {:aps => {:badge => badge, :alert => alert_message},   :device_tokens => [token]})
 end
end

I keep getting a 400 bad request when I test this in the console. Any ideas as to what the problem is? I know that urban airship needs a 'content-type:application/json' in the request header, but that should be covered in the model. Thanks in advance, Jack

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top