I am using pubnub android kotlin sdk for chat function. However i have 3 different fragments on which i use pubnub's functions. H
ence i have created a service which listens to incomings events from pubnub and post it on fragments as a part of ui.
There are multiple channels on 3 different fragments. One fragment is for one to one messaging and another fragment is for group messaging. I subscribe channels on the each fragment whenever i open the fragment but do not unsubscribe when i leave the fragment. Currently my pubnub works well whenever i open the first fragment for one to one messaging but when i open another fragment for group messaging the listener on the first fragment stops listening to incoming messages or events.
My question here is, shall i subscribe all the channels once in the first time or subscribe each on their corresponding fragment page. Also i would like to know what is the best practice to use pubnub in android kotlin. Sharing the code is little bit difficult for me.