开发者

Where do I get the device token that Urban Airship requires for iOS registration?

From the online API:

An HTTP PUT to /api/device_tokens/ registers a device token on our end. This lets us know that the device token is active, and sh开发者_开发技巧ould happen every time the application is opened to ensure that the list of device tokens remains up-to-date.

How do I go about acquiring the device token in the first place?


I believe you need to look here: implement the application:didRegisterForRemoteNotificationsWithDeviceToken method to receive the device token.

EDIT: the Urban Airship guide is at http://urbanairship.com/docs/apns_test_client.html.

EDIT: The only way to send an APNS message is using the device token: you have to pass the device token back to whichever non-Apple server is the origination point for the notification. There are 3 logical entities in the transaction: the device, the APNS server (Apple's backend), and the originating server (in this case Urban Airship's server). The device and Apple's backend have the token already (or can generate it). The Urban Airship server only gets that token when you send it to them from the device. It can then use that token to communicate with the APNS backend and identify the device. What you do is you use the application:didRegisterForRemoteNotificationsWithDeviceToken callback and then you send (via HTTP, or whatever other wire protocol you so choose) that token to the originating server (the Urban Airship docs show you how do that with their library). Their server can now use that token to communicate with the APNS backend.


To get the device token, you have a few options:

Option 1

You can find it as one of the arguments sent in your app delegate's application:didRegisterForRemoteNotificationsWithDeviceToken: method.

Option 2

You can get it as an NSString by calling [[UAPush shared] deviceToken] after your device has successfully registered for remote notifications.

Option 3

If you don't have access to the code. You can find it by reading your app's calls to urban airship. You can do this with Charles proxy. Full instructions at this link. To sum it up:

  1. Install the Charles certificate on your iOS device be going to http://charlesproxy.com/charles.crt in safari on your device.
  2. Proxy your device's wireless connection through Charles
  3. Enable SSL Proxying in Charles for *.urbanairship.com on port 443.
  4. Run your app and look for calls to urls that mention "urbanairship" that have been recorded in Charles. They should be decrypted and some will include info about your device token.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜