2

I couldn't find any api in PubNub documentation to list device tokens associated with a channel. I am planning to associate users to their respective channels, and link their device tokens directly to those channels, so that if same user is signing in from different devices, they get all push notifications meant for them, as from server side, we would be publishing changes on channels. But now on some later point of time we might need to retrieve device tokens associated with those channels how to do that ?

As of now we were not planning to store device token on our app sever, thinking that we would retrieve it from PubNub via channels, but we couldn't find any relevant api.

Please help, also let us know if the design is not correct.

Thanks!

Ankit Jain
  • 798
  • 8
  • 20
  • 1
    Not sure why you got downvoted. I'd like to see the reasons because this is a legit question. I countered one of the downvotes with my upvote. See my answer below. – Craig Conover Feb 12 '16 at 23:36

1 Answers1

2

PubNub Mobile Push Gateway - Device Token/Channel Lookup

PubNub does not currently provide a way to get device tokens for a given channel because this is considered unsecure. If you (whoever you is: client device, server, third party, etc.) should either know the device token or not. If you can not get the device token by some valid/legitimate means, then you should not be able to get by some other means (like by PubNub channel association).

What you can do is have the device POST its token to your server along with a list of PubNub channels it should register to for push notifications and store them in your database and maintain that list as these device token/channel associations change.

You can always list the channels for a given device using the SDK's specific API:

Or use this REST API:

http://pubsub.pubnub.com/v1/push/sub-key/your_sub_key/devices/your_device_token?type=push_type

where push_type is gcm, apns or mpns.

Community
  • 1
  • 1
Craig Conover
  • 4,710
  • 34
  • 59
  • Hy Craig, i didn't find the method pubnub.requestPushNotificationEnabledChannelsForDeviceRegistrationId in PubNub 4.0. What is the replacement of this method? – Ovi Jan 23 '17 at 06:11
  • which PubNub SDK are you using? – Craig Conover Jan 23 '17 at 18:22
  • Must be Java SDK 4.x. [These are the docs you are looking for](https://www.pubnub.com/docs/java/api-reference-sdk-v4#adding-device-channel). – Craig Conover Jan 23 '17 at 18:41
  • yes it was. This method should be deprecated but pubnub deleted it in new sdk :\ alas – Ovi Jan 23 '17 at 19:03
  • Not deprecated because 4x is not backwards compatible. It was a complete rewrite, hence the major version change from 3 to 4 instead of a new 3.x. All of our 4x SDKs are newly implemented with coding standards that comply to the language's conventions. – Craig Conover Jan 24 '17 at 18:58