Skip to main content
UIKit apps follow the same configure-then-show pattern as SwiftUI, with one extra step: you must explicitly attach the Candid overlay to a UIViewController so the SDK knows where to anchor its research bubble and modal screens. Use Candid.attachUIKitOverlay(to:) right after you set your window’s root view controller, and call Candid.register(trigger:) whenever you want a study to start. (In SDK versions before 0.2.0 this method was named attachOverlay(to:).)

Configure the SDK

Call Candid.configure(_:) once at launch, before your app presents any UI. AppDelegate.application(_:didFinishLaunchingWithOptions:) and SceneDelegate.scene(_:willConnectTo:options:) are both appropriate places.
If your app uses the scene-based lifecycle, configure in SceneDelegate instead:

Attach the overlay

After you assign a root view controller to your UIWindow, call Candid.attachUIKitOverlay(to:) with that same root controller. The SDK adds a transparent overlay view above your app’s interface to host the research bubble and modal screens. The overlay only intercepts touches that land on visible Candid UI; everything else passes through to your app.
Pass your root view controller, the one assigned to window.rootViewController, not a child, tab, or presented controller. Attaching to a child controller clips the overlay to that controller’s view bounds and breaks the layout of the research bubble.

Register a trigger

Call Candid.register(trigger:) wherever it makes sense in your app flow. Candid fetches the currently running study from your dashboard and presents it over your content.
1

From a UIButton action

2

In viewDidAppear

3

After a condition

Detach the overlay

Call Candid.detachUIKitOverlay() when you no longer need the research UI, for example, when the user logs out or when a particular scene is torn down.
You can re-attach the overlay at any time by calling Candid.attachUIKitOverlay(to:) again with a new root controller.
If your app replaces its root view controller at runtime (for example, switching from an onboarding flow to the main app), call Candid.detachUIKitOverlay() before the swap and Candid.attachUIKitOverlay(to:) with the new root controller after it.