城市飞艇。使用 /api/apis/ 方法获取 Android APID
我一直在尝试使用 Urban Airship 提供的服务器端 api 与我的 Android 应用程序集成。我正在尝试从我的 Android 应用程序获取在 Urban Airship 服务器中注册的所有 APID。尽管我已经注册了 3 个设备(模拟器注册)并且我可以在 https 中查看它们,但我总是得到 Null 值分别使用我的应用程序密钥和秘密作为用户名和密码登录后:://go.urbanairship.com/api/apis/。
Urban Airship 提供了使用公开的服务器端 REST api 的方法(jave 代码)。对于 Urban Airship 未提供的功能,开发人员必须编写自己的方法。没有获取 APID 的方法,因此我按照其他方法编写了此方法。
public DeviceTokensResponse getApids() throws URISyntaxException
{
return get(DeviceTokensResponse.class, "/api/apids/");
}
我使用相同的服务器端 api 通过 api /api/device_tokens/ 成功获取存储在 Urban Airship 服务器中的 iPhone 设备令牌。 在下面找到获取 iPhone 设备令牌的代码。这给出了预期的结果。
public DeviceTokensResponse getDeviceTokens() throws URISyntaxException
{
return get(DeviceTokensResponse.class, "/api/device_tokens/");
}
很抱歉询问有关城市飞艇等特定产品的问题。我看到Urban Airship的创始人在这个论坛上很活跃,所以我毫不犹豫地提出了这个问题。请帮我解决这个问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题,创建了一个名为 ApidList.java (具有 List 属性)和 Apid.java (具有与 json 标签键名称相对应的属性)的自定义类。一旦存在 json 键名称和类属性的一对一映射,响应对象就会正确填充。如果映射失败,则会返回一个空对象(这就是我之前发生的情况)
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)