/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Migration guide

Copy link

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

Copy link

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

Copy link

The following breaking changes have been made to the Chat SDK v4 for iOS.

Structural changes

Copy link
  • Remove the SBD prefix across names for all constants, protocols, classes, enums, and type definitions.

  • Rename the main class from SBDMain to SendbirdChat.

  • Creation of Sendbird instances is no longer available in v4.

  • Rename SBDError to SBError.

  • Add didConnect(userId:) and didDisconnect(userId:) to ConnectionDelegate.

  • Split SBDChannelDelegate into BaseChannelDelegate, GroupChannelDelegate, and OpenChannelDelegate.

  • Remove SBDUserListQuery. Use specific queries such as ApplicationUserListQuery and BlockedUserListQuery to query users instead.

  • Add the requestId to the file onProgress interface. Change interface FileMessagesWithProgressHandler and fun onProgress(bytesSent: Int, totalBytesSent: Int, totalBytesToSend: Int) to fun onProgress(requestId: String, bytesSent: Int, totalBytesSent: Int, totalBytesToSend: Int)

  • Separate existing params such as SBDUserMessageParams into UserMessageCreateParams and UserMessageUpdateParams.

  • The default value of the GroupChannel class’s members property has been changed from nil to [].

  • The default value of the User class’s nickname property has been changed from nil to "".

From v3To v4

SBDGroupChannelParams

GroupChannelCreateParams
GroupChannelUpdateParams

SBDOpenChannelParams

OpenChannelCreateParams
OpenChannelUpdateParams

SBDUserMessageParams

UserMessageCreateParams
UserMessageUpdateParams

SBDFileMessageParams

FileMessageCreateParams
FileMessageUpdateParams

Name changes

Copy link
From v3To v4

SBDMain

SendbirdChat

The SBD prefix for constants, protocols, classes, enums, and type definitions

All SBD prefix removed

SBDError

SBError

SendBirdError

SendbirdError

SBDOptions

SendbirdChatOptions

SendbirdChat.Options.useMemberAsMessageSender

SendbirdChat.Options.useMemberInfoInMessage

getChannelCount

getGroupChannelCount

getChannelCountWithMemberStateFilter:...

getGroupChannelCountWithMemberStateFilter:...

getMyGroupChannelChangeLogs(ByTimestamp ...)

getMyGroupChannelChangeLogs(timestamp)

getMyGroupChannelChangeLogs(ByToken ...)

getMyGroupChannelChangeLogs(token)

isUsingLocalCaching

isLocalCachingEnabled

memberStateFilter: MemberStateFilter

myMemberStateFilter: MyMemberStateFilter

channelDidUpdateReadReceipt

channelDidUpdateReadStatus

channelDidUpdateDeliveryReceipt

channelDidUpdateDeliveryStatus

Note: A full list of name changes will be available soon.

Other changes

Copy link
  • 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 corresponding Params 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

Copy link

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

Copy link

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

Copy link

Find and replace all instances of SBDError with SBError.

Step 3 Replace SBDMain

Copy link

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

Copy link

Find and remove all the SBD prefix from all names for constants, protocols, classes, enums, and other type declarations.

Step 5 Handle common errors

Copy link

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 and completionHandler 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.

func updateChannelInfo() {
   channel.update(withName:"Some new name", coverImage: imageData, coverImageName: "image.jpg", data: nil, operatorUserIds: nil, customType: nil, progressHandler: nil) { (channel, error) in
      // ...
   }
}
let openChannelUpdateParams = OpenChannelUpdateParams()
openChannelUpdateParams.name = "Some new name"
openChannelUpdateParams.coverImage = imageData
openChannelUpdateParams.coverImageName = "image.jpg"

channel.update(params: openChannelUpdateParams) { channel, error in
   // ...
}

Errors with assigning nil in parameter

Copy link

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.

let fileMessageParams = FileMessageCreateParams(file: imageData)
fileMessageParams.fileName = imageName
fileMessageParams.mimeType = mimeType
fileMessageParams.fileSize = UInt(imageData.count)
fileMessageParams.thumbnailSizes = [thumbnailSize] as [ThumbnailSize]
fileMessageParams.data = nil
fileMessageParams.customType = nil
let fileMessageParams = FileMessageCreateParams(file: imageData)
fileMessageParams.fileName = imageName
fileMessageParams.mimeType = mimeType
fileMessageParams.fileSize = UInt(imageData.count)
fileMessageParams.thumbnailSizes = [thumbnailSize] as [ThumbnailSize]

Channel delegate errors

Copy link

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

Copy link

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.

private var userListQuery: UserListQuery?
if self.userListQuery == nil {
   switch userListType {
   case .banned:
      self.userListQuery = channel.createBannedUserListQuery { $0.limit = 20 }
   case .muted:
     self.userListQuery = channel.createMutedUserListQuery { $0.limit = 20 }
   case .participant:
     self.userListQuery = channel.createParticipantUserListQuery { $0.limit = 20 }
   }
}
private var bannedUserListQuery: BannedUserListQuery?
private var mutedUserListQuery: MutedUserListQuery?
private var participantListQuery: ParticipantUserListQuery?

switch userListType {
   case .banned:
      self.bannedUserListQuery = channel.createBannedUserListQuery()
   case .muted:
      self.mutedUserListQuery = channel.createMutedUserListQuery()
   case .participant:
      self.participantUserListQuery = channel.createParticipantUserListQuery()
}