iFrame
This document provides instructions for integrating the Onboarding process into an iFrame.
<iframe
src="https://cadastro.io/:token"
allow="geolocation;camera;fullscreen;accelerometer;gyroscope;magnetometer;"
allowfullscreen="true"
style="width: 100vw; height: 100vh; border: 0"
></iframe>iOS Sensor Permission Requirements for iProov
Complete implementation example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Onboarding iframe Example</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #f5f5f5;
}
#startButton {
padding: 16px 32px;
font-size: 18px;
background: #051f61;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
}
#startButton:hover {
background: #1fd660;
}
iframe {
display: none;
width: 100%;
height: 100vh;
border: none;
}
</style>
</head>
<body>
<!-- Step 1: Show button to request sensor permission -->
<button id="startButton">Start Onboarding</button>
<!-- Step 2: Onboarding iframe (hidden initially) -->
<!-- IMPORTANT: Replace :token with your actual onboarding token -->
<iframe
style="width: 100vw; height: 100vh; border: 0"
id="onboardingIframe"
allow="geolocation; camera; fullscreen; accelerometer; gyroscope; magnetometer"
src="https://cadastro.io/:token"
allowfullscreen="true"
></iframe>
<script>
// IMPORTANT: This script must run on the PARENT PAGE that hosts the iframe
// iOS requires sensor permissions to be requested from the parent page, not from within the iframe
// When user clicks the button
document
.getElementById("startButton")
.addEventListener("click", async () => {
try {
// Check if device requires motion permission (iOS 13+ Safari)
if (typeof DeviceMotionEvent.requestPermission === "function") {
// Request permission from the parent page (required for iOS)
const permission = await DeviceMotionEvent.requestPermission();
if (permission === "granted") {
// Permission granted - show iframe
showIframe();
} else {
// Permission denied
alert(
"Sensor access is required for face verification. Please allow access in your browser settings."
);
}
} else {
// No permission needed (Android, Desktop, older iOS)
showIframe();
}
} catch (error) {
console.error("Error:", error);
alert(
"Error requesting permissions. Please try again or check your browser settings."
);
}
});
// Function to show the iframe
function showIframe() {
document.getElementById("startButton").style.display = "none";
document.getElementById("onboardingIframe").style.display = "block";
}
// Optional: Listen for messages from the iframe
window.addEventListener("message", (event) => {
// Validate origin for security
// IMPORTANT: Replace with your onboarding domain
if (event.origin !== "https://cadastro.io") return;
// Handle onboarding completion or other events
console.log("Onboarding event:", event.data);
});
</script>
</body>
</html>Last updated

