Search code examples
androidandroid-c2dmurbanairship.com

Urban Airship. Get Android APIDs using /api/apids/ method


I have been trying to use the server side api provided by Urban Airship to integrate with my Android app. I am trying to get all the APIDs registered in Urban Airship server from my Android app. I am getting a Null value always although I have registered 3 devices(emulator registration) and I can view them in https://go.urbanairship.com/api/apids/ after logging in using my app key and secret as username and password respectively.

Urban Airship has provided methods(jave code) to use the server side REST api exposed. Developers have to write their own method for functionalities that are not provided by Urban Airship. there was no method for getting APIDs , hence I wrote this method in line with the other methods.

    public DeviceTokensResponse getApids() throws URISyntaxException
{
    return get(DeviceTokensResponse.class, "/api/apids/"); 
}

I used the same server side api to successfully fetch the iPhone device tokens stored in the Urban Airship server using the api /api/device_tokens/ . FInd below the code for fetching iPhone device tokens. This is giving the expected results.

    public DeviceTokensResponse getDeviceTokens() throws URISyntaxException
{
    return get(DeviceTokensResponse.class, "/api/device_tokens/"); 
}

I'm sorry for asking a question about a specific product like Urban Airship. I have seen the founders of Urban Airship active in this forum, hence I did not hesitate to post this question. Kindly help me with this.


Solution

  • I solved it creating a custom class called ApidList.java (which has List property)and Apid.java (which has properties corresponding to json tag key names). Once there is a one-to-one mapping of json key names and class properties , response object is populated correctly. In case the mapping fails, a null object is returned ( that is what happened to me previously)