Compose Multiplatform
Environment Setup
Our Chat SDK uses Moko Resources to include the internal assets in the SDK for iOS.
Since iOS doesn’t bundle resources for static frameworks, we have to add the Moko resource plugin and setup the environment properly for inclusion.
Step 1: Update Gradle
Step 2: Add Build Phase to XCode
Per the documentation from Moko here, we need to add a Run Script Build Phase with the following script:
Be sure to update shared
with the name of your shared module. The Multiplatform Wizard usually uses shared
or composeApp
.
Step 3: Setup Cocoapods
Add a podfile with GoogleMaps and Giphy:
Setup cocoapods in gradle:
Quick Start
In order to display any of the UI components and access chat data, you must first initialize the SDK and log in as a chat user.
Step 1: Initialize the SDK
In each platform (Android/iOS), call BotStacksChat.shared.setup with your API key. You can obtain your API key from the Botstacks Dashboard. If you don’t yet have an account, you can create one for FREE!
Android
iOS
Note, you can optionally delay load and later call BotStacksChat.shared.load
to load BotStacks in whatever load sequence you wish.
If you’d like Giphy support in your chats, send your Giphy API key during setup
.
Step 2: Logging in
Nearly all functionality is within the context of a chat user. That said, you must first be logged in as a chat user in order to appropriately display the UI components.
To log in, call the login function prior to displaying any UI components. Below is an example of how to accomplish this.
Step 3: Render the UI
The BotStacks UI Kit uses Jetpack Compose (Multiplatform). There are a plethora of navigation protocols for Compose Multiplatform, so pick whatever one works best for your app.
Our Sample uses Voyager, so we simply make a screen for the controller, drop it in and navigate to it. Our sample makes use of a commonized approach to give both iOS and Android platforms specific bottom sheet implementations to keep apps, respective of the platform they are on.
Step 4: Theming
You can theme your BotStacks UI kit by modifying the defaults of the BotStacksThemeEngine
. The theme supports fonts, colors, assets, and dimensions. Configure it like this:
Was this page helpful?