Skip to content

Integration guide

Asklify + iOS (Swift)

WKWebView renders the hosted chat page as a native-feeling support screen. SwiftUI and UIKit both work — the template covers SwiftUI.

Prerequisite: an Asklify project with some knowledge added — the quickstart covers that in a couple of minutes. You'll need your public project ID (pub_...) from Widget → Install.
1

Add the chat view

Copy the template below. No extra dependencies — WKWebView ships with iOS.

2

Present it

SettingsView.swift
NavigationLink("Contact support") {
    SupportChatView()
        .navigationTitle("Support")
        .navigationBarTitleDisplayMode(.inline)
}

Ready-to-use template

Copy, paste, replace the project ID — that's the whole integration:

SupportChatView.swift
import SwiftUI
import WebKit

/// Hosted Asklify chat inside a WKWebView.
struct SupportChatView: UIViewRepresentable {
    private let chatURL = URL(string: "https://app.asklify.in/widget/pub_YOUR_PROJECT_ID")!

    func makeUIView(context: Context) -> WKWebView {
        let config = WKWebViewConfiguration()
        config.websiteDataStore = .default() // persist conversation history
        let webView = WKWebView(frame: .zero, configuration: config)
        webView.load(URLRequest(url: chatURL))
        return webView
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {}
}

Customization

All appearance and behavior — name, greeting, colors, theme, position, suggested questions — is configured in your dashboard under Widget settings and applies instantly without redeploying. See the widget configuration reference.

Event handling

To react to what happens in conversations — a chat starting, a customer requesting a human, feedback submitted — subscribe to webhooks. For fully custom experiences, the REST API exposes chat with streaming, knowledge search, and conversation transcripts.

Best practices

  • The default website data store persists the visitor's conversation between launches.
  • App Transport Security needs no exceptions — the chat URL is HTTPS.
  • For fully native UI, proxy the REST /chat API through your backend and stream deltas into your own views.
Never bundle a secret API key (sk_...) in a mobile app — extractable in minutes. Mobile apps should use the hosted chat page (as above) or talk to your own backend, which holds the key.

Troubleshooting

  • White screen — confirm the project's hosted chat URL is correct (pub_ ID) and reachable in Safari.
  • Keyboard overlaps input — WKWebView handles this automatically inside a navigation view; avoid fixed-height containers.

Still stuck? Check the error reference or email hello@asklify.in.