Get subscribed channels for a user

Showing JavaScript examples.

This guide shows you how to call Where Now to list which channels a User ID is currently subscribed to. Presence must be enabled on the keyset, and new keysets have it enabled by default. Most applications already know which channels a client subscribes to, since they're the ones that subscribed it. Reach for this call mainly when testing and troubleshooting, not as part of your regular application logic.

Where Now requires no channel-level permission when Access Manager is enabled because it looks up a User ID rather than a channel.

Get channels for the current client​

Call Where Now with no User ID, or with the client's own User ID, depending on your SDK.

1

Most PubNub SDKs default to the client's own User ID when you omit one, though some expect you to pass it explicitly. The JavaScript example above passes it explicitly. Check the parameter table in your platform's API reference before assuming which applies.

Get channels for another User ID​

Pass a specific User ID to look up a different client instead of the one making the call.

No JavaScript example here. Showing Python:

1envelope = pubnub.where_now() \
2 .uuid('some-other-user-id') \
3 .sync()

A User ID that connects with multiple devices returns the union of channels across all of them, since presence tracks the User ID, not the individual connection. Refer to Presence for what that means when the same User ID has more than one device connected at once.

Was this page useful?

Last updated on