Velos Mobile
Published in

Velos Mobile

Announcing SendbirdCombine — Combine extensions for the Sendbird chat SDK.

Edit: We gave a talk recently at a Sendbird Code Cafe and chatted about our experience with Sendbird and how to get the most out of SendbirdCombine. Check it out on YouTube!

Are you creating a modern, reactive iOS chat app with Sendbird but find yourself having to implement non-reactive design patterns utilized by the Sendbird SDK?

SendbirdCombine is a Swift library that bridges Apple’s reactive Combine framework built into iOS 13+ with the messaging functionality provided by the Sendbird SDK.

So why should I use SendbirdCombine?

The asynchronous messaging APIs provided by the Sendbird SDK are implemented using multiple completion handler closures and registering delegate callbacks for each view controller that needs to listen for them. While these methods are perfectly functional, they can be somewhat unwieldy. The single processing chain provided by Combine makes your code more maintainable, readable, and less error-prone.

Let’s break that down with some examples.

Here’s how you’d connect to a Sendbird instance using SendbirdCombine:

To send a text message on a channel:

To listen for channel events:

The advantages of using Combine become more apparent when you chain multiple operations that would normally require nested closures and/or DispatchGroups. Say we want to retrieve a SBDOpenChannel by URL, and then simultaneously enter the retrieved channel and also download its metadata. Without SendbirdCombine, your code might look something like this:

But if we use SendbirdCombine, our code looks more like this:

Much easier to maintain and read!

Sounds good, but where do I get it?

SendbirdCombine is supported in iOS 13+ and Swift 5 projects and is available as a CocoaPod. Simply add the following line into your Podfile to get started:

pod 'SendBirdCombine'

There’s also support for using the new SendBirdCalls framework to make in-app voice/video calls with SendbirdCombine. Add the following line instead to add call support (in addition to the base messaging support):

pod 'SendBirdCombine/Calls'

This is enabled separately since SendBirdCalls includes a large embedded binary that you probably don’t want if you’re not using it, so make sure you enable git lfs support on your system if using Callsto properly download the binary and avoid a runtime crash.

You can find additional setup instructions and examples in the README. Happy chatting!

Velos Mobile is a Mobile Design & Development Agency in San Francisco. Drop us a note if you would like to chat about anything mobile!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store