Migration guide
Sendbird Chat SDK v4 for iOS has introduced major breaking changes to streamline the code structure and enhance its scalability.
This page explains the breaking changes and provides a step-by-step guide for migrating to v4.
Requirements
The minimum requirements for v4 are the following.
- macOS
- Xcode 15 and later
- At least one device running iOS 12.0 and later
- Swift 5.0 and later or Objective-C
Breaking changes
The following breaking changes have been made to the Chat SDK v4 for iOS.
Structural changes
-
Remove the SBD prefix across names for all constants, protocols, classes, enums, and type definitions.
-
Rename the main class from
SBDMain
toSendbirdChat
. -
Creation of
Sendbird
instances is no longer available in v4. -
Rename
SBDError
toSBError
. -
Add
didConnect(userId:)
anddidDisconnect(userId:)
toConnectionDelegate
. -
Split
SBDChannelDelegate
intoBaseChannelDelegate
,GroupChannelDelegate
, andOpenChannelDelegate
. -
Remove
SBDUserListQuery
. Use specific queries such asApplicationUserListQuery
andBlockedUserListQuery
to query users instead. -
Add the
requestId
to the fileonProgress
interface. Changeinterface FileMessagesWithProgressHandler
andfun onProgress(bytesSent: Int, totalBytesSent: Int, totalBytesToSend: Int)
tofun onProgress(requestId: String, bytesSent: Int, totalBytesSent: Int, totalBytesToSend: Int)
-
Separate existing params such as
SBDUserMessageParams
intoUserMessageCreateParams
andUserMessageUpdateParams
. -
The default value of the
GroupChannel
class’smembers
property has been changed fromnil
to[]
. -
The default value of the
User
class’snickname
property has been changed fromnil
to""
.
From v3 | To v4 |
---|---|
|
|
|
|
|
|
|
|
Name changes
From v3 | To v4 |
---|---|
|
|
The | All |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note: A full list of name changes will be available soon.
Other changes
-
Remove
SBDConnectionManager
, which was deprecated in v3. -
Local caching in the SDK v4 can facilitate caching-related functionalities and more. SyncManager will soon be deprecated, so we highly recommend using local caching instead.
-
Remove setters for
Query
classes and add correspondingParams
classes. -
Mappable protocol is no longer supported. Instead, use Swift's Codable to serialize and deserialize objects. It stays the same for Objective-C.
Migrating to v4
The following is a step-by-step guide which covers the changes and key steps required when migrating from the Chat SDK v3 to v4.
Sendbird Chat SDK v4 will likely prevent your app from compiling until all migration tasks are complete and all errors are fixed. After fixing all the blocking errors, further work may be needed to remove warnings and re-align the SDK with your app. We recommend you allow a generous timeline for the task. Depending on the level of dependency, it may take a few hours to a week.
Step 1 Replace SDK import names
It's recommended to remove any deprecated methods from the Chat SDK v3 since v4 will likely have a long list of errors. Find and replace all instances of import SendBirdSDK
with import SendbirdChatSDK
. Notice that the "b" in Sendbird
is now lowercase.
Step 2 Replace SBDError
Find and replace all instances of SBDError
with SBError
.
Step 3 Replace SBDMain
Find and replace all instances of SBDMain
with SendbirdChat
.
Note: You must initialize the
SendbirdChat
instance before calling any SDK interfaces.
Step 4 Remove the prefix SBD
Find and remove all the SBD
prefix from all names for constants, protocols, classes, enums, and other type declarations.
Step 5 Handle common errors
The following are manual fixes to errors that may arise when migrating to v4.
Note: For best performance, subclassing isn't recommended in v4. Using subclassing may result in errors that demand more time to be resolved.
The following are possible method-related errors you may see in Xcode.
- Missing arguments for parameters
params
andcompletionHandler
in call. - Extra arguments at positions #1, #2, #3, #4, #5, #6, #8 in call.
- Extra argument in call.
For example, updating channel information with individual parameters as in v3 may cause one or more of the errors listed above.
In v4, you can fix the error by externally declaring method params using the following code.
Errors with assigning nil
in parameter
In v4, some parameter fields don't need to be explicitly assigned as nil. The following errors may be seen in Xcode.
- Type of expression is ambiguous without more context.
nil
requires a contextual type.
The nil
assigned fields, data and customType can be deleted because the SDK will automatically assign the values as nil
.
Channel delegate errors
SBDChannelDelegate
is split into BaseChannelDelegate
, GroupChannelDelegate
, and OpenChannelDelegate
. Therefore, the previous channel delegate needs to be changed and may throw the following error in Xcode.
- Cannot find type
ChannelDelegate
in scope.
In this case, the suggested fix is to consider the context of the class to determine which delegate is required. For example, AppDelegate
likely requires BaseChannelDelegate
instead of the original SBDChannelDelegate
.
Name change errors
In v4, some of the param classes have been separated and renamed. For example, GroupChannelParams
was split into GroupChannelCreateParams
or GroupChannelUpdateParams
. Thus, the following error may be seen in Xcode.
- Cannot find type
XXXParams
in scope.
In this case, the suggested fix is to use Xcode's autocomplete, or refer to Sendbird Docs to find relevant name changes.
In v3, casting MutedUserListQuery
, BannedUserListQuery
, and ParticipantListQuery
to UserListQuery
was possible.
In v4, the changes made to the query model no longer works in the same pattern as in v3. UserListQuery
has changed to ApplicationUserListQuery
and each query type must be declared individually.