WebView integration
4 min read
The WebView integration renders the Footprint onboarding flow inside a native sheet that you control: a page sheet on iOS, a bottom sheet on Android, with your own back button, close button, and toolbar styling. onboarding.initialize, by contrast, launches the flow in an in-app browser.
@onefootprint/footprint-expo version 3.4.0 or higher.Camera permissions
If your onboarding flow includes identity document verification, declare camera permissions in your app's app.json (or app.config.js). The WebView runs inside your app, so your app's manifest and Info.plist gate the camera prompt, not a system browser.
json
Start an onboarding
- Wrap your app in
FootprintWebViewProvider. The provider mounts the native sheet that hosts the Footprint WebView. It must be an ancestor of every component that callsuseFootprintWebView().
javascript1import { FootprintWebViewProvider } from "@onefootprint/footprint-expo";
2
3export default function App() {
4 return (
5 <FootprintWebViewProvider>
6 {/* The rest of your app */}
7 </FootprintWebViewProvider>
8 );
9}
- Create an onboarding session. Call POST /onboardings and keep the onboarding session token it returns, such as
obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH. - Launch the flow with the
useFootprintWebViewhook. When the user taps a button, for example, callinitializewith theonboardingSessionTokenand anonCompletecallback.
javascript1import { useFootprintWebView } from "@onefootprint/footprint-expo";
2import { View, Button } from "react-native";
3
4const Screen = () => {
5 const { initialize } = useFootprintWebView();
6
7 const launch = () => {
8 initialize({
9 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
10 onComplete: (validationToken) => {
11 console.log(validationToken);
12 },
13 });
14 };
15
16 return (
17 <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
18 <Button onPress={launch} title="Launch Footprint" />
19 </View>
20 );
21};
Handle the result
When the user completes the flow, onComplete receives a validationToken. Post it to your backend for further processing.
The SDK also reports errors, cancellation, and closing. Pass onError, onCancel, and onClose to initialize:
typescript1initialize({
2 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
3 onComplete: (validationToken) => {
4 console.log(validationToken);
5 },
6 onError: (error) => {
7 console.log(error);
8 },
9 onCancel: () => {
10 console.log("User canceled the flow");
11 },
12 onClose: () => {
13 console.log("User closed the flow");
14 },
15});
onCancel fires when the user taps the close button in the toolbar, swipes the sheet down, or taps the backdrop (Android).
Customize the appearance
Pass an appearance object to initialize to change the look of the flow:
typescript1initialize({
2 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
3 onComplete: (validationToken) => {
4 console.log(validationToken);
5 },
6 appearance: {
7 variables: {
8 borderRadius: "8px",
9 colorSuccess: "#10b981",
10 colorError: "#F87171",
11 buttonPrimaryBg: "#5550e9",
12 },
13 },
14});
The customization guide lists every variable.
Style the sheet and toolbar
Beyond the in-flow appearance, you can style the native sheet and the toolbar that wraps it. The toolbar shows the Footprint domain, a close button, and, when relevant, a back button.
typescript1initialize({
2 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
3 onComplete: (validationToken) => {
4 console.log(validationToken);
5 },
6 sheetStyle: {
7 backgroundColor: "#ffffff",
8 },
9 toolbarStyle: {
10 backgroundColor: "#ffffff",
11 buttonColor: "#000000",
12 textColor: "#000000",
13 separatorColor: "#c8c8cc",
14 },
15 options: {
16 hideFootprintUrl: false,
17 },
18});
Available props
| Variable | Description |
|---|---|
onboardingSessionToken | The onboarding session token you created. |
onComplete | Triggered after the user completes the onboarding flow. You receive a validationToken that your backend can exchange with Footprint to see the fp_id, the login method used, and the KYC status. |
onError | Optional. Called when there was an unrecoverable error while initializing the onboarding flow. It receives an error string with more details. |
onCancel | Triggered when the user abandons the flow: tapping the close button in the toolbar, swiping the sheet down, or tapping the backdrop. |
onClose | Triggered when the user closes the flow, whether completed or canceled. |
appearance | Optional. A FootprintAppearance object that customizes the look of your integration. |
l10n | Optional. The desired localization. See Localization configuration. |
redirectUri | Optional. The URI scheme of your app, used to redirect back to your app from any external steps inside the flow. |
sheetStyle | Optional. { backgroundColor }. Controls the background color of the sheet that contains the WebView. |
toolbarStyle | Optional. { backgroundColor, buttonColor, textColor, separatorColor }. Controls the appearance of the toolbar at the top of the sheet. |
options | Optional. { hideFootprintUrl }. When true, hides the Footprint domain from the toolbar. |
Next steps
- Handle the decision validates the token on your backend and reads the onboarding status.
- Changelog lists notable releases of
@onefootprint/footprint-expo.