The Onside Delegate
Customize OnsideKit with OnsideDelegate — host window scene, window level, per-screen theme override, login routing, and a pre-login region hint.
OnsideDelegate lets you tune how OnsideKit presents its screens and routes login. Every method has a default implementation, so implement only the ones you need.
protocol OnsideDelegate: AnyObject {
@MainActor func onside(hostWindowSceneForScreen screen: OnsideScreen) -> UIWindowScene?
@MainActor func onside(uiWindowLevelOverrideForScreen screen: OnsideScreen) -> UIWindow.Level?
@MainActor func onside(uiThemeOverrideForScreen screen: OnsideScreen) -> OnsideUIThemeMode?
@MainActor func onsideLoginMethod() -> OnsideLoginMethod
@MainActor func onsideDefaultCountryCodeAssumption() -> String?
@MainActor func onsideShouldOverrideHostSupportedInterfaceOrientations() -> Bool
}Assign your delegate (keep a strong reference — it's held weakly), typically at launch:
@main
final class AppDelegate: UIResponder, UIApplicationDelegate, OnsideDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Onside.initialize()
Onside.delegate = self
return true
}
}OnsideScreen
Several delegate methods receive the screen OnsideKit is about to present:
Host window scene
OnsideKit presents each screen in its own OnsideSDKWindow (a UIWindow subclass), created in the scene this method returns — useful in multi-window apps. If you return nil (the default), OnsideKit picks a connected scene itself, preferring a .foregroundActive one, then .foregroundInactive, then any connected window scene.
Window level
Set the windowLevel of the window OnsideKit presents the screen in. Return nil (the default) to let OnsideKit choose it, which is what most apps want:
If the scene has no visible window above
UIWindow.Level.normal, the SDK window stays at.normal— the behaviour apps have always had.Otherwise the SDK window is placed one level above the topmost visible window in the scene, so its UI is not covered by your elevated windows.
The automatic level never goes above
UIWindow.Level.alert - 1, leaving system alerts and the keyboard on top. Windows far above the alert level (system-owned ones, such as the keyboard window) are ignored when picking the level.
Return an explicit level to take over — for example to keep the SDK below a window of yours that must always stay on top:
An explicit level is applied as-is, without the automatic elevation, so it is also the way to place the SDK window above a window of yours sitting at UIWindow.Level.alert or higher.
When the screen is dismissed, OnsideKit removes its window. If it still holds key-window status, it restores the previous eligible host window or another visible eligible window in the same scene. It does not take focus back from a window that has already become key.
Per-screen theme override
Force a theme for a specific screen, overriding the global theme and the system appearance:
.light/.dark— force that theme.auto— follow the system settingnil(default) — no override; fall back to the global theme, then the system theme
Login method
.auto(default) — try the Onside store app when available and a callback scheme is configured; otherwise use the SDK phone login..local— use the SDK phone login without the store-app handoff.
An assigned Onside.externalLoginDelegate takes priority. This method selects the regular login route when external login is disabled or falls back. See External Login.
Orientation and window resizing
SDK screens use portrait orientation by default, including in landscape-only host apps. OnsideKit applies its orientation override to active SDK windows and restores the host window’s supported orientations when its UI closes. Its sheets and navigation layouts adapt when the scene is resized; on iPadOS 26, the SDK window also accounts for the system window controls.
Return false only if your app handles the orientation policy itself. In that case, allow portrait for SDK windows in your host orientation callback:
OnsideSDKWindow is created and managed by the SDK; you do not create it yourself. Opting out does not select a landscape SDK layout. If the host excludes portrait, the SDK uses the host’s allowed orientations to avoid an empty orientation mask.
Pre-login region hint
Provide an ISO 3166-1 alpha-2 country code (e.g. "US", "DE") to use as the region before the user logs in, improving logged-out pricing and availability. Return nil (default) to use the device region. Once the user logs in, the account's region is used and this hint is ignored. See Regions & Storefronts.
Last updated
Was this helpful?