Sendbird Local Caching for iOS sample (Swift)
Local caching enables Sendbird Chat SDK for iOS to locally cache and retrieve group channel and message data. This facilitates offline messaging by allowing the SDK to create a channel list view or a chat view in a prompt manner and display them even when a client app is in offline mode. Provided here is a Local Caching for iOS sample to experience first-hand the benefits of Sendbird's Local Caching.
Find out more about Sendbird Local Caching for iOS on Local Caching for iOS doc. If you have any comments or questions regarding bugs and feature requests, visit Sendbird community.
This section shows you the prerequisites you need to check for using Sendbird Chat SDK for iOS.
The minimum requirements for Chat SDK for iOS are:
- iOS 11.0+
- Xcode 14.1+
- Chat SDK for iOS 3.1.0 or higher
Try the sample app using your data If you would like to try the sample app specifically fit to your usage, you can do so by replacing the default sample app ID with yours, which you can obtain by creating your Sendbird application from the dashboard. Furthermore, you could also add data of your choice on the dashboard to test. This will allow you to experience the sample app with data from your Sendbird application.
This section gives you information you need to get started with Local Caching for iOS.
Create a project to get started: Sendbird for iOS supports both Objective-C and Swift.
Installing the Chat SDK is a simple process if you’re familiar with using external libraries or SDK’s in your projects. You can install the Chat SDK using CocoaPods
or Carthage
like the following.
Open a terminal window. Navigate to the project directory, and then open the Podfile
by running the following command:
$ pod init
On Podfile
, add the following lines:
platform :ios, '9.0'
use_frameworks!
target YOUR_PROJECT_TARGET do
pod 'SendBirdSDK', '~> 3.1.0'
end
Install the SendBird
framework through CocoaPods
.
$ pod install
Now you can run your project with the SendBird
framework by opening *YOUR_PROJECT*.xcworkspace
. If you don't want to use CocoaPods
, check out the manual installation guide.
- Add
github "sendbird/sendbird-ios-framework"
to yourCartfile
. - Run
carthage update
. - Go to your Xcode project's General settings tab. Open the
<YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build/iOS
in the Finder window and dragSendBirdSDK.framework
to the Embedded Binaries section in Xcode. Make sure theCopy items if needed
option is selected and clickFinish
. - On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
- Add the paths to the frameworks you want to use under Input Files. For example:
$(SRCROOT)/Carthage/Build/iOS/SendBirdSDK.framework
- Add the paths to the copied frameworks to the Output Files. For example:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SendBirdSDK.framework
For an in depth guide, read on from Adding frameworks to an application.