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 UIKit initialization.
To integrate and run Sendbird UIKit in your app, you need to first initialize the SendbirdUI instance through AppDelegate.
If you haven't modified the initialization parameters, InitParams, Sendbird UIKit works based on local caching and synchronization and won't proceed to the next step until the initialization is complete. We recommend displaying a loading indicator to show the initialization process so that other succeeding steps should wait. The indicator should be displayed when startHandler is called and hidden when completionHandler is called.
Note: Local caching has been used so that the client app can locally cache and retrieve channel and message data. This functionality requires the database to be reset and migrated. As a result of DB migration in the server, the initialization process of the SendbirdUI instance is synchronous. If the database successfully migrates, you can proceed to the next step.
// AppDelegate.swift
import SendbirdUIKit
func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey:Any]?)->Bool{letAPP_ID="YOUR_APP_ID"// Specify your Sendbird application ID.SendbirdUI.initialize(
applicationId: APP_ID
){ params in// This is the builder block where you can modify the initParameter.//// [example]// params.needsSynchorous = false} startHandler:{// This is the origin.// Initialization of SendbirdUIKit has started.// e,g. Show a loading indicator.} migrationHandler:{// DB migration has started.} completionHandler:{ error in// If DB migration is successful, proceed to the next step.// If DB migration fails, an error exists.// e,g. Hide the loading indicator.}}
The initParamsBuilder of the initialize(applicationId:initParamsBuilder:migrationHandler:completionHandler:) function of the SendbirdUI class allows you to modify the use of local caching and the synchronization settings of the initialization task.
If you are using local caching but don't need to use SendbirdUIKit'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 SendbirdUIKit's 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 Sendbird UIKit 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 UIKit initialization.
To integrate and run Sendbird UIKit in your app, you need to first initialize the
SendbirdUI
instance throughAppDelegate
.If you haven't modified the initialization parameters,
InitParams
, Sendbird UIKit works based on local caching and synchronization and won't proceed to the next step until the initialization is complete. We recommend displaying a loading indicator to show the initialization process so that other succeeding steps should wait. The indicator should be displayed whenstartHandler
is called and hidden whencompletionHandler
is called.The
initParamsBuilder
of theinitialize(applicationId:initParamsBuilder:migrationHandler:completionHandler:)
function of theSendbirdUI
class allows you to modify the use of local caching and the synchronization settings of the initialization task.If you are using local caching but don't need to use SendbirdUIKit'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 SendbirdUIKit's 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