Hello,
I’m working on the app which is required to support switching among some environments with different Sendbird app ID.
But once SendbirdChat.init
is called with one application id, it seems it doesn’t update itself anymore on call init with a different ID.
first call
const instance = SendbirdChat.init({
appId: "applicationIdFirst",
modules: [new GroupChannelModule()],
});
console.log(instance.appId)
=> prints “applicationIdFirst” (what we expected)
and then second call…
const instance = SendbirdChat.init({
appId: "applicationIdSecond",
modules: [new GroupChannelModule()],
});
console.log(instance.appId)
=> prints “applicationIdFirst” (appId is not updated!)
It seems SendbirdChat stores its instance and returns it on the second call - how can we resolve the issue?
We’re using:
“@sendbird/chat”: “4.7.2”,
“react”: “18.2.0”,
“react-native”: “0.72.3”,
1 Like
It looks specifying newInstance: true
returns a new instance, but it does not update SendbirdChat.instance
.
const instance = SendbirdChat.init({
appId: "applicationIdSecond",
modules: [new GroupChannelModule()],
newInstance: true,
});
I’m dealing with this same problem, though we use the SendbirdUIKitContainer
and update the appId
that is passed into it, which would ideally update the SendbirdChat instance.
We have a multi-tenant setup with the potential for a single end user to belong to multiple organizations/Sendbird apps. To support this, we have the ability in our app for a user to change their Sendbird app at runtime, similar to changing orgs in Slack.
When the active organization ID changes in our redux store, that triggers a series of hooks to run, including changing the appId
that is passed into the SendbirdUIKitContainer
. I also call await disconnect()
and await connect()
in response to changing the org. Logs show that the connect()
call succeeds and sdk.connectionState
is OPEN
. Sendbird’s internal logs also show success here.
However, the UI fragments from @sendbird/uikit-react-native
which are mounted in the app have their own network requests running, and the logs start showing [debug] fail api request [SendbirdError: Connection is required.]
. I assume this is related to the SDK instance not being updated properly.
(Both of these apps work correctly if I use them to initialize Sendbird on app launch, only switching between them causes the connection error.)
Question:
Is changing the Sendbird app ID supported at runtime in the React Native and JS SDKs? I asked about this scenario before, but no limitation was mentioned.
@Chinmaya_Gupta You were very helpful before. Could you please respond here?