5 min read
The WebView integration runs your Footprint onboarding flow in a native sheet: a page sheet on iOS and a bottom sheet on Android. You control the back button, close button, and toolbar styling. onboarding.initialize opens the flow in an in-app browser.
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.
json1{
2 "expo": {
3 "ios": {
4 "infoPlist": {
5 "NSCameraUsageDescription": "We use the camera to verify your identity documents."
6 }
7 },
8 "android": {
9 "permissions": ["android.permission.CAMERA"]
10 }
11 }
12}
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_xxx. - 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_xxx",
10 onComplete: ({ onboardingId }) => {
11 console.log(onboardingId);
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 { validationToken, onboardingId }. Send the onboardingId to your backend and read the result with GET /onboardings/{id}. The ID comes from the device, so check that it matches the id your backend got from POST /onboardings for this user before you act on the result. validationToken is deprecated and will be removed, so use onboardingId when possible.
onComplete received the validation token as a plain string. To upgrade, change (validationToken) => to ({ validationToken }) =>.The SDK also reports errors, cancellation, and closing. Pass onError, onCancel, and onClose to initialize:
typescript1initialize({
2 onboardingSessionToken: "obtok_xxx",
3 onComplete: ({ onboardingId }) => {
4 console.log(onboardingId);
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_xxx",
3 onComplete: ({ onboardingId }) => {
4 console.log(onboardingId);
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_xxx",
3 onComplete: ({ onboardingId }) => {
4 console.log(onboardingId);
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 { validationToken, onboardingId }. Read the result with GET /onboardings/{onboardingId}. |
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 reads the onboarding result on your backend.
- Changelog lists notable releases of
@onefootprint/footprint-expo.