Custom WebView adapter
Advanced

Custom WebView adapter

Use the SDK-owned WebView unless you need custom presentation and can implement the session and callback contract. For initial activation or recovery, implement WalletOnboardingWebView. For account linking, implement WalletAccountLinkingWebView. The SDK still chooses the step, forms the URL and confirms every step with the API; your adapter owns everything that happens inside the WebView.

The interface

fun interface WalletOnboardingWebView {
    suspend fun open(url: String, step: WalletOnboardingStep)
}

open receives the SDK-formed URL and the step (AIS, GRIFFIN or PIS). It must present a WebView and suspend until the form's callback returns control. If the user dismisses the WebView, throw WolletteException(WolletteErrorKind.CANCELLED) on Android or WolletteError(kind: .cancelled) on iOS.

Public adapter limits

The public adapter receives only url and step; it does not receive a consumer token or a session-injection callback. Hosted login keeps its session private and exposes no public token getter. Use SDK-owned presentation with hosted login unless Wollette supplies a supported custom-session mechanism.

A custom adapter needs the current token from an approved host-managed consumer-session integration that your app already owns and renews. Inject it securely on the trusted form origin before scripts run, as described in the session contract. Do not read SDK storage or put tokens in URLs to work around this boundary.

The built-in Griffin saved flow also uses an internal signal that the public adapter cannot emit. A normal open return starts API confirmation; it does not reproduce save-and-return. Use the built-in presenter if you need that behaviour until the SDK exposes a public contract. Do not convert saved into user cancellation: cancellation can clear saved recovery context.

Support account linking

The linking adapter must also expose the new AIS consent ID:

interface WalletAccountLinkingWebView : WalletOnboardingWebView {
    suspend fun completedAisConsentId(): String?
}

Capture data.consentId only from a valid AIS finished message from the trusted main frame. Clear the previous captured value before each new AIS opening. addAccount rejects a missing or previously existing consent ID with INVALID_RESPONSE; the SDK checks completion through the API. The legacy complete string cannot supply this ID.

Call walletOnboarding.addAccount with this adapter. resumePendingRegistration accepts the base adapter because it already has the saved AIS target. Keep the complete SDK entry URL, including flow=add-account and resume=pis on a recovered PIS entry. On a bank return, use the documented continuation URL and preserve flow=add-account; the native continuation does not copy resume=pis or every entry query parameter. See bank returns.

Use it

// Initial activation; check pendingProgress first on a returning session.
val result = sdk.walletOnboarding.start(webViewAdapter, provider)

Ordinary completion, failure and user dismissal feed the same API-confirmation state machine. The built-in draft-save path has the public-adapter limitation above. A callback is only a signal to re-check the API; returning from open does not mark the step as done. If the callback arrives before the server has processed the step, the SDK polls for about 30 seconds and continues through confirmed Griffin states within the same call.

Map valid callbacks explicitly:

Callback or interruptionAdapter action
Trusted finished for the active stepReturn normally from open; the SDK confirms server state
Trusted failedThrow core ONBOARDING_FAILED / .onboardingFailed
User dismissal or trusted cancelledThrow core CANCELLED / .cancelled
Coroutine/Task cancellationPreserve native cancellation; do not replace it with a user-dismissal result
Griffin savedNot publicly expressible as the built-in save-and-return signal; use SDK-owned presentation

What your adapter must implement

Everything the SDK-owned host does for you:

ResponsibilityWhat the SDK-owned host does
Session injectionUses its internal session access to set window.WOLLETTE_SESSION and the matching localStorage entry before page scripts run, on the form origin only
Callback captureAccepts WOLLETTE_NATIVE.postMessage from the form's main frame on the form origin and returns control on a terminal event
Bank returns (AIS, PIS)Detects the backend callback URL for the active step and reloads the hosted continuation page
Identity-provider return (Griffin)Polls the registration while an external page is open and reloads the Griffin form when the status changes
open_urlOpens an HTTPS link in the device browser without closing the form
Storage cleanupClears the form origin's storage on clear and on consumer switch
Camera (Android)Requests permission and grants the WebView video capture only

The exact messages, URLs and paths are in Hosted form contract. The native restoration mechanisms are provided only by the SDK-owned hosts; an adapter has its own storage lifecycle and must reproduce them.