Announcing SendbirdCombine — Combine extensions for the Sendbird chat SDK.
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?
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:
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):
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! email@example.com