Add in-app support to an iOS app
Give your iPhone and iPad app a "Get help" button that shares your app's screen with your support team, with consent, in your own name.
Give your iOS app a "Get help" button: your customer taps it and agrees, and your support team sees your app's screen in the GaiaDesk console — and, if you allow it, guides them through it — without the customer installing anything.
GaiaDesk's iOS SDK, GaiaDeskEmbed 0.1.0, works with iOS 15 and later, on iPhone and iPad, from UIKit and SwiftUI. It is a Swift package (and a CocoaPod), open source (MIT), at github.com/Gaia-Desk/gaiadesk-embed-ios. It wraps the same signed native library, libgaiadesk_embed, as GaiaDesk's other embed SDKs, as a prebuilt static XCFramework that is linked, unmodified, into your app. For how the SDKs fit together, see in-app support.
What your customer sees
One button. Your app shows "Get help" wherever you put it.
A consent dialog. It names your company, says that your team will see this app's screen and nothing outside it, and whether they will be able to guide it. Nothing is shared until the customer agrees.
iOS's own screen recording prompt. The first time, iOS asks whether to allow screen recording in your app, and shows its own recording indication while it runs.
An indicator for as long as anything is shared. "Sharing with Acme · Stop", a pill at the top of the screen, above everything your app draws. Your app cannot hide it: the library sends frames only while it is on screen and uncovered. In a guided session it also has Pause control.
A support code. Nine digits your customer can read to an agent over the phone.
When the session ends — the customer presses Stop, your app stops it, the session expires, or the app quits — sharing stops at once and nothing is left behind: no extension, nothing installed, nothing written to disk.
What your support team sees
Agents open Support in the GaiaDesk console, see the waiting customer (with the details your backend passed) and join, or type the support code. Only your own account and team can join, and only team members with a support seat.
1. Add the package
Swift Package Manager
In Xcode, choose File → Add Package Dependencies…, enter https://github.com/Gaia-Desk/gaiadesk-embed-ios, and add the GaiaDeskEmbed library to your app target. Or, in a Package.swift:
dependencies: [
.package(url: "https://github.com/Gaia-Desk/gaiadesk-embed-ios.git", from: "0.1.0"),
],
targets: [
.target(name: "YourApp", dependencies: [
.product(name: "GaiaDeskEmbed", package: "gaiadesk-embed-ios"),
]),
]CocoaPods
The pod is not on CocoaPods trunk yet. Point your Podfile at the release's podspec, then run pod install:
platform :ios, '15.0'
target 'YourApp' do
pod 'GaiaDeskEmbed', :podspec => 'https://raw.githubusercontent.com/Gaia-Desk/gaiadesk-embed-ios/v0.1.0/GaiaDeskEmbed.podspec'
endUse :podspec, not :git: the library is not in git, so a :git checkout has no binary. It works with and without use_frameworks!.
2. The native library
There is nothing to bundle by hand. Swift Package Manager downloads GaiaDeskEmbedFFI.xcframework.zip from the GitHub release and checks it against the checksum pinned in the package; CocoaPods downloads the release's pod archive and checks its SHA-256. The XCFramework holds the library for devices (arm64) and the Simulator (arm64 and x86_64), and is linked statically into your app. Include its licence, LICENSE-BINARY, in your app's notices.
3. Create sessions from your backend
The iOS SDK starts a session from an embed token, which your backend gets from GaiaDesk. That way your server decides who may get help, and the customer details it passes show as verified in the console.
Create the session with a secret API key (scope support):
curl -s -X POST https://api.gaiadesk.net/v1/support/sessions \
-H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
-d '{"mode": "view", "customer": {"name": "Ada", "plan": "pro"}}'The response carries embed_token (gdemb_…). Hand only that to your app. Never ship the secret key in your app: the embed token is all it needs. The full request is in the support API reference.
4. Add the button
A SwiftUI button. fetchEmbedToken() stands for your own call to your backend.
import GaiaDeskEmbed
import SwiftUI
@MainActor
final class HelpModel: ObservableObject {
@Published var status = ""
@Published var sharing = false
private var help: GaiaDeskEmbed?
func getHelp() async {
if let help { help.stop(); return } // the button is "Stop sharing" while a session runs
guard let consent = await GaiaDeskEmbed.requestConsent(company: "Acme") else { return }
do {
let token = try await fetchEmbedToken()
help = try GaiaDeskEmbed.start(.init(embedToken: token, company: "Acme"), consent: consent) { [weak self] event in
self?.on(event)
}
sharing = true
} catch let e as GaiaDeskEmbedError {
status = "Could not start: \(e.message) (\(e.code))"
} catch {
status = "Could not get help: \(error.localizedDescription)"
}
}
private func on(_ event: GaiaDeskEmbed.Event) {
switch event {
case let .code(code, _, _): status = "Your support code is \(code)"
case let .joined(agent): status = "\(agent ?? "An agent") is viewing this app"
case .ended: help = nil; sharing = false
default: break
}
}
}
struct HelpButton: View {
@StateObject private var model = HelpModel()
var body: some View {
VStack {
Button(model.sharing ? "Stop sharing" : "Get help") { Task { await model.getHelp() } }
Text(model.status)
}
}
}That is the whole integration. Call start on the main thread; events arrive on the main queue, and .ended(reason:) is always the last one — stopped (the customer), app_stopped (your stop()), disconnected, expired or error. One session runs at a time: a second start throws GaiaDeskEmbedError with code busy.
Consent
start takes a Consent, and the library refuses to start without one. requestConsent(company:guided:from:) shows the SDK's own dialog (an alert with "Share" and "Don't Share") and returns nil when the customer declines. To use your own dialog, call recordConsent(company:guided:) when the customer says yes, and never without asking. A consent is single-use, expires after 10 minutes, and must match the session: the same company, and guided only if the dialog said your team may guide.
Your name
company names you on the consent dialog and the indicator: "Sharing with Acme · Stop". This SDK has no colour or logo options: the dialog is a standard iOS alert, and the indicator has a fixed look.
Guided sessions
By default your team can only look. To let them guide, create the session as cobrowse ("mode": "cobrowse") and pass guided: true in the configuration and to requestConsent — both ends must want it. Your customer can pause it at any time from the indicator; your app can too (setPaused(true)). A pause your customer chose can only be lifted by them: setPaused(false) is ignored until they do.
iOS has no public way to synthesise a touch, so guided input is partial, delivered inside your app through public UIKit API only. The console tells the agent so.
The agent | What happens in your app |
|---|---|
clicks a | its action fires (buttons: |
clicks a table or collection cell | it is selected through your delegate |
clicks anything else (SwiftUI views, custom gestures, web content) | your customer sees a "Tap here" ring at that spot |
scrolls | the |
types, or presses Enter, Backspace, Left, Right, Home, End or Escape | delivered to the first responder |
moves the pointer or highlights | a pointer dot or ring is drawn over your app |
Anything refused arrives as .action(_, applied: false, reason:): on the indicator, on a masked region, into a password field, or while your app is not active. If focus is in a secret field the SDK cannot recognise (a custom one), call setSecretFocus(true) while it is, and typing is refused.
Keeping things private
Your app only, always. The default capture,
.replayKit, is ReplayKit's in-app capture: iOS itself limits it to your app..snapshotdraws your app's own windows instead, with no system prompt, but misses content drawn outside UIKit (some video, Metal). Other apps, the Home Screen and system UI are never captured, and sharing pauses when your app leaves the foreground. No frame is sent while another process's screen is shown over your app — a photo picker, Safari, a share sheet, a document picker, mail or message compose.Masks. Mark sensitive SwiftUI views with
.gaiaDeskMasked(); pass UIKit views' rectangles at start (GaiaDeskEmbed.rectInWindow(cardView)gives one, in your key window's points):Text(card.number).gaiaDeskMasked()let masks = [GaiaDeskEmbed.rectInWindow(cardView)].compactMap { $0 } help = try GaiaDeskEmbed.start(.init(embedToken: token, company: "Acme", maskedRects: masks), consent: consent) { _ in }Masked areas are painted black before a frame is encoded. Start-time masks and marked SwiftUI views cover the very first frame. Later,
setMaskedViews(_:)orsetMaskedRects(_:)replace the set; masked views are measured again for every frame, so they stay covered as they move. Every secure text field on screen is masked without being asked. While the screen is in transition (a navigation push, a sheet, the keyboard), everything is masked until it settles. If the app's window cannot be located, or the masks cannot be applied, the whole picture is painted out or no frame is sent.Consent every time. The library refuses to start without it; there is no setting that skips the dialog or hides the indicator.
What each platform supports
Capture | Guided input | Consent dialog | |
|---|---|---|---|
iPhone and iPad, iOS 15 or later | this app | partial | iOS alert, or your own |
iOS Simulator | this app ( | partial | iOS alert, or your own |
Test on a real device. ReplayKit is not available in the Simulator; set
captureMethod: .snapshotthere.Screen recording: iOS asks your customer the first time a session uses ReplayKit.
.snapshotneeds no permission.
What is and is not permitted
You may: ship the prebuilt library unmodified inside your app, with its licence in your app's notices; offer support sessions to your own customers; name your company on the dialog and indicator.
You may not: modify, decompile or re-sign the library separately from your app; hide or imitate the indicator; start a session without your customer's agreement.
See the SDK's README for every option, event and error code.