How Do You Unsubscribe from a Pub/Sub Channel?

How do you unsubscribe from a pub/sub messaging channel? For example, User A logs out of the app and then User B logs in, you would want to unsubscribe from the User A’s channels during the logout process and subscribe to the User B’s relevant channels on login. Or, for example, User A no longer wishes to receive messages from a specific pub/sub channel, how would I unsubscribe them?

You can use the following method to cancel a subscription: