You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basics of the improved Sendbird ChatSDK initialization.
Now, initialize the Chat SDK in the app to allow the Chat SDK to respond to changes according to the connection status in iOS client apps. Initialization requires your Sendbird application's APP_ID, which can be found on Sendbird Dashboard.
The completionHandler method gets the initialization status through different event handlers. The migrationStartHandler method is called when there's an upgrade in the local database. Meanwhile, the completionHandler method informs the client app whether the initialization is complete.
If you are using local caching but don't need to use Sendbird's features immediately after launching your app, you can make the migration process of local caching asynchronous by setting the needsSynchronous parameter of the InitParams object to false. This will reduce the initialization time when the app is launched to minimize runtime. (If you don't use local caching, there's no difference in app launching time because there's no migration process).
Also, if you have a situation where a SendbirdChat function is called asynchronously from another class or method, independent of SendbirdChat's initialization, use the SendbirdChat class's executeOrWaitForInitialization(executeHandler:) feature.
You can set it to execute immediately if it's initialized, or wait for initialization if it's not.
SendbirdChat.executeOrWaitForInitialization{// Implement logic to perform once initialization is complete}
Note: The executeOrWaitForInitialization(executeHandler:) method of a SendbirdChat instance must be set after calling Chat initialization method.
Sequence diagram
Below is a sequence diagram to help you understand.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Basics of the improved Sendbird ChatSDK initialization.
Now, initialize the Chat SDK in the app to allow the Chat SDK to respond to changes according to the connection status in iOS client apps. Initialization requires your Sendbird application's
APP_ID
, which can be found on Sendbird Dashboard.Before calling the
initialize(params:migrationStartHandler:completionHandler:)
method, create anInitParams
object with your Sendbird application ID. In the params, you can also determine whether to enable local caching or not and whether to make initialization synchronously.The
completionHandler
method gets the initialization status through different event handlers. ThemigrationStartHandler
method is called when there's an upgrade in the local database. Meanwhile, thecompletionHandler
method informs the client app whether the initialization is complete.If the initialization fails when you set
isLocalCachingEnabled
totrue
, the SDK will operate normally and change the value ofisLocalCachingEnabled
tofalse
. If you still wish to use local caching, clear the database usingclearCachedData(completionHandler:)
and try the initialization again withisLocalCachingEnabled
set totrue
.If you are using local caching but don't need to use Sendbird's features immediately after launching your app, you can make the migration process of local caching asynchronous by setting the
needsSynchronous
parameter of theInitParams
object tofalse
. This will reduce the initialization time when the app is launched to minimize runtime. (If you don't use local caching, there's no difference in app launching time because there's no migration process).Also, if you have a situation where a SendbirdChat function is called asynchronously from another class or method, independent of SendbirdChat's initialization, use the SendbirdChat class's
executeOrWaitForInitialization(executeHandler:)
feature.You can set it to execute immediately if it's initialized, or wait for initialization if it's not.
Sequence diagram
Below is a sequence diagram to help you understand.
Synchronous
Asynchronous
Beta Was this translation helpful? Give feedback.
All reactions