WebView iOS and Android
The WebView option allows individuals to verify their identity in a mobile app with the Android WebView or iOS WKWebView.
Mobile WebView Integration (iOS & Android)
For a seamless, in-app user experience, you can embed the Trust Swiftly verification flow within your native mobile app using a WebView component. This guide will walk you through the implementation for both Android and iOS.
The core technology is the same Magic Link used in web integrations, but with a specific pattern to control the user flow.
The Core Concept: The "Redirect-to-Close" Pattern
This is the most important concept for a successful WebView integration.
Get the Link: Your app gets a unique
magic_linkfor a user from your backend.Provide a Redirect URL: When your backend creates or requests the user link from the Trust Swiftly API, it must include a
redirect_url. This URL should be a custom, non-existent URL that your app can uniquely identify (e.g.,https://yourapp.com/verification-complete).Open the WebView: Your app opens the
magic_linkin a full-screen WebView.User Completes Flow: The user completes the verification steps inside the WebView.
Trust Swiftly Redirects: Upon completion, our server redirects the WebView to the
redirect_urlyou provided.Your App Intercepts the Redirect: Your app's native code must listen for navigation events within the WebView. When it detects the WebView attempting to navigate to your specific
redirect_url, it knows the process is complete.Your App Closes the WebView: Upon detecting the redirect, your app programmatically closes the WebView and returns the user to your native UI.
This pattern ensures a smooth transition back to your application without the user getting "stuck" on a "verification complete" page inside the WebView.
Android WebView Guide
WebView GuideStep 1: Configure Permissions & Manifest
First, ensure your AndroidManifest.xml includes the necessary permissions for camera access and is configured to handle the WebView activity.
Step 2: Implement the WebView Activity
Create a dedicated Activity to host the WebView. This code provides a complete, robust implementation that handles permissions, file uploads, and the critical redirect-to-close pattern.
Step 3: Launch the Activity
From another part of your app, launch the TrustSwiftlyWebViewActivity and pass the magic_link.
iOS WKWebView Guide
WKWebView GuideStep 1: Configure Permissions (Info.plist)
Your app must include an entry for NSCameraUsageDescription in its Info.plist file to explain why it needs camera access.
Step 2: Implement the WebView Controller
Create a dedicated UIViewController to manage the WKWebView. This controller will handle loading the URL, delegating permissions, and intercepting the final redirect.
Step 3: Present the Controller (SwiftUI Example)
From your main application view, present the TrustSwiftlyWebViewController as a sheet.
Common Issues
❗️Multiple signups
If testing your app and creating multiple verify sessions you should clear the cookies and cache of WKWebView inbetween new user sessions. (Refer to this guide)
❗️Webkit Inline Media Playback
Please ensure
allowsInlineMediaPlaybackis enabled when creating a webview on a webkit browser (mobile Safari). This defaults to false and the camera preview will incorrectly open as a fullscreen live broadcast.
❗Camera Configuration
The WebView Flow requires access to the device camera. Please include the
NSCameraUsageDescriptionkey your app'sInfo.plistfile as described in the Apple Developer documentation.
❗️Allow External Network Requests
Trust Swiftly makes external network calls within the Inquiry Flow that need to be allowlisted for the flow to properly function. Certain frameworks such as Cordova require such requests to be allow listed. Please include
*.trustswiftly.com/*in such an allow list if needed
Make sure permissions are correctly set for your app bundle.
Camera and Microphone Permission

Last updated