Pubnub list devicetoken associated with a channel?

494 views Asked by At

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!

1

There are 1 answers

5
Craig Conover On BEST ANSWER

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.