Permalink
Browse files

Merge pull request #17 from thrillcall/master

Support Urbanairship.unregister_device for Android with :provider => :android
  • Loading branch information...
joeyschoblaska committed Oct 3, 2012
2 parents 6e4456b + e3abb83 commit a2d58453f973edf0aa99f5a0f62e6ba98d61d20b
Showing with 19 additions and 2 deletions.
  1. +6 −2 lib/urbanairship.rb
  2. +13 −0 spec/urbanairship_spec.rb
View
@@ -26,8 +26,12 @@ def register_device(device_token, options = {})
end
end
- def unregister_device(device_token)
- do_request(:delete, "/api/device_tokens/#{device_token}", :authenticate_with => :application_secret)
+ def unregister_device(device_token, options = {})
+ if (options[:provider] || @provider) == :android
+ do_request(:delete, "/api/apids/#{device_token}", :authenticate_with => :application_secret)
+ else
+ do_request(:delete, "/api/device_tokens/#{device_token}", :authenticate_with => :application_secret)
+ end
end
def delete_scheduled_push(param)
View
@@ -162,6 +162,19 @@
Urbanairship.application_key = "bad_key"
Urbanairship.unregister_device("key_to_delete").success?.should == false
end
+
+ it "uses the android interface if 'provider' configuration option is set to :android" do
+ Urbanairship.provider = :android
+ Urbanairship.unregister_device("new_device_token")
+ FakeWeb.last_request.path.should == "/api/apids/new_device_token"
+ Urbanairship.provider = nil
+ end
+
+ it "uses the android interface if 'provider' option is passed as :android" do
+ Urbanairship.unregister_device("new_device_token", :provider => :android)
+ FakeWeb.last_request.path.should == "/api/apids/new_device_token"
+ end
+
end
describe "::delete_scheduled_push" do

0 comments on commit a2d5845

Please sign in to comment.