Before you start
- An iOS app that targets iOS 15 or later
- Use
https://usechatting.comasbaseURL - Use your site/workspace ID inside Chatting as
siteId - Choose Swift Package Manager or CocoaPods
- If you want background reply notifications, configure APNs in your app target too
That is the full default setup: baseURL is always https://usechatting.com, and siteId is your site/workspace ID inside Chatting.
This guide is for the iOS app integrating the SDK.
If you run Chatting itself, your backend-side setup is separate: deploy Chatting with APPLE_TEAM_ID, APPLE_KEY_ID, and APPLE_PUSH_KEY_P8. The rest of this guide is app-side iOS setup.
Install the SDK
- SwiftPM: add
https://github.com/codelinglabs/chatting.gitfrom version1.0.0and includeChattingSDKorChattingSDKUI - CocoaPods: add
pod 'ChattingSDK'orpod 'ChattingSDK/Core'to your Podfile
// Swift Package Manager
.package(url: "https://github.com/codelinglabs/chatting.git", from: "1.0.0")# Podfile
pod 'ChattingSDK'Create the client
Create one ChattingClient with your Chatting URL and site ID.
import ChattingSDK
let client = ChattingClient(
baseURL: URL(string: "https://usechatting.com")!,
siteId: "your-site-id"
)Present the support screen
Present ChattingConversationView from a sheet or your support flow.
import SwiftUI
import ChattingSDK
import ChattingSDKUI
struct ContentView: View {
@State private var isShowingSupport = false
private let client = ChattingClient(
baseURL: URL(string: "https://usechatting.com")!,
siteId: "your-site-id"
)
var body: some View {
Button("Contact support") {
isShowingSupport = true
}
.buttonStyle(.borderedProminent)
.sheet(isPresented: $isShowingSupport) {
SupportChatSheet(client: client)
}
}
}
private struct SupportChatSheet: View {
private let viewModel: ChattingConversationViewModel
init(client: ChattingClient) {
viewModel = ChattingConversationViewModel(client: client)
}
var body: some View {
NavigationStack {
ChattingConversationView(
viewModel: viewModel,
context: ChattingVisitorContext(pageURL: URL(string: "myapp://support"))
)
.navigationTitle("Support")
.navigationBarTitleDisplayMode(.inline)
}
}
}This gives you a native support screen with conversation history, sending, typing, and email capture.
Identify signed-in users
If your app already knows the customer, identify them when the support screen opens. If not, you can save an email address only.
private struct SupportChatSheet: View {
private let viewModel: ChattingConversationViewModel
private let signedInEmail: String?
private let signedInName: String?
private let draftVisitorEmail: String?
init(
client: ChattingClient,
signedInEmail: String?,
signedInName: String?,
draftVisitorEmail: String?
) {
viewModel = ChattingConversationViewModel(client: client)
self.signedInEmail = signedInEmail
self.signedInName = signedInName
self.draftVisitorEmail = draftVisitorEmail
}
var body: some View {
NavigationStack {
ChattingConversationView(viewModel: viewModel)
.task {
if let signedInEmail {
viewModel.identify(
ChattingVisitorProfile(
email: signedInEmail,
name: signedInName
)
)
} else if let draftVisitorEmail {
viewModel.emailAddress = draftVisitorEmail
viewModel.saveEmail()
}
}
}
}
}Use identify(...) for signed-in users. Use emailAddress plus saveEmail() when you only need a follow-up email.
Register APNs push notifications
- Request notification permission in your iOS app
- Register for remote notifications
- Pass the APNs device token into
ChattingClient
import ChattingSDK
import UIKit
func registerChattingPush(client: ChattingClient, deviceToken: Data) {
let token = deviceToken.map { String(format: "%02x", $0) }.joined()
guard let bundleId = Bundle.main.bundleIdentifier else {
return
}
Task {
try? await client.registerPushToken(
ChattingPushRegistration(
pushToken: token,
bundleId: bundleId,
environment: .production
)
)
}
}Open the same support screen after a push tap. ChattingConversationView reconnects and reloads the current conversation when the app becomes active again.
Check the installation
- Open the support screen in your app
- Send a test message from the device
- Reply from the Chatting inbox
- Confirm the reply appears in the app while it is still open
- If APNs is configured, background the app, reply from the inbox, tap the push notification, and confirm the same conversation reloads
What works today
- Foreground chat works today
- APNs-backed reply notifications work when your host app registers an APNs token
- Conversation state is persisted per visitor session
- The SwiftUI wrapper reconnects and reloads when the app becomes active again
- Attachment uploads are available through the core SDK message API
For the app integrating the SDK, the remaining iOS work is normal APNs setup: entitlements, notification permission prompts, and forwarding the APNs token into ChattingClient.
FAQ
Do we have to use the SwiftUI wrapper?
No. You can use ChattingClient on its own and build your own UI around the core SDK models and transport methods.
Can we install it with CocoaPods instead of SwiftPM?
Yes. pod 'ChattingSDK' installs the full package, and pod 'ChattingSDK/Core' gives you the core layer without the SwiftUI surface.
What should I use for baseURL?
Use https://usechatting.com.
Ready to add native chat?
Install the SDK, add your site ID, and launch one support screen in your app first.
Open Chatting