iOS
Native Swift chat SDK with a SwiftUI chat screen: AI chatbot, live-agent handoff, attachments and typing indicators. iOS 14+, Swift 5.9.
Installlink
Swift PM (note the lowercase package name):
.package(url: "https://github.com/talktothelaw/new-instance-livechat.git", from: "0.1.0")
// target dependency:
.product(name: "LiveAndAiChat", package: "liveandaichat-ios")CocoaPods: pod 'LiveAndAiChat', '~> 0.1.0'
Quick startlink
import LiveAndAiChat
let chat = try LiveAndAiChat.Builder()
.config(try LiveAndAiChatConfig(apiKey: "sk_live_abc123"))
.user(ChatUser(customerName: "Ada", customerId: "usr_123", customerEmail: "ada@example.com"))
.build()
chat.present(from: viewController)UIKit hosts call present(from:), which presents the screen and wires the built-in document picker. SwiftUI hosts embed ChatScreen(sdk:onClose:onPickFile:) directly. Unlike Android, openChat() presents no UI on iOS: it flips state and starts initialize(); the host presents the screen.
Configurationlink
| Field | Default | Notes |
|---|---|---|
apiKey | required | Publishable widget key ID; a blank key throws, a keyId:secret value warns and strips the secret |
baseUrl | https://service.newinstance.cloud | Release builds reject overrides |
gqlPath / ssePath / wsPath | /service / /graphql/stream / /graphql/ws | Transport paths |
transport / initialMessage | inherited / - | Overrides |
The config initialiser throws, and ChatUser requires a non-empty customerName.
API surfacelink
initialize, openChat, closeChat, sendMessage, attachFile(data:name:mimeType:previewUri:), removeAttachment, retryMessage, requestHandoff(reason:), sendTypingStart / sendTypingStop, destroy, addDelegate / removeDelegate; LiveAndAiChat.current() returns the most recently built instance.
State: @Published orgConfig, connectionState and lifecycle, plus derived flowState, messages, conversation, assignment, agentTyping, unreadCount, widgetOpen. Delegate callbacks (all optional): didReceiveMessage, didSendMessage, agentTypingDidChange, connectionStateDidChange, didEncounterError. Errors are .network, .validation, .auth, .system with recoverable; lifecycle == .failed means call initialize() again.
Platform noteslink
- No Info.plist usage keys are required: attachments use the system document picker. Add a Photos usage description only if your app saves chat images.
- UI strings are inline English; there is no localisation override today, and no push support.
destroy()makes the instance unusable (a later call trips a precondition); build a new instance to start again.