pusher/libPusher

Dynamic Channels

jqn opened this issue · 4 comments

jqn commented

I've been looking everywhere and I can't find a single example where subscriptions are not hardcoded like this PTPusherChannel *channel = [self.client subscribeToChannelNamed:@"chat"];

Has anyone implemented this library with Dynamic channels?

A channel is defined by its name and so dynamic channels don't quite make sense, if I'm understanding correctly .

If you want a client to subscribe to a different channel then you need to make a new subscription to a new channel with a new channel name.

Maybe I'm misunderstanding exactly what you're trying to achieve?

jqn commented

Hi @hamchapman, what I meant was to allow the user of the app to choose a channel. I'm unsure on how to pass the channel name from lets say a dropdown with a list of channels. The user would choose one channel and the chosen channel would then be passed down to [self.client subscribeToChannelNamed:@"chosenchannel"]; and I haven't found any examples on how to do that.

Ah okay, that's just something that you'd need to build yourself. So you'd create a dropdown in your app UI and wire it up to a ViewController (or something similar) and then when the dropdown item is selected you'd run a function that would then subscribe to relevant channel (based on the dropdown value selected, presumably).

jqn commented

Thanks @hamchapman. I appreciate the help.