Iframe Integration (H5)
This section provides a comprehensive guide to integrating the AAI iframe into your application. It includes steps for embedding the iframe, handling events, and interpreting the event codes.
1. Enabling Iframe Mode
To enable iframe integration mode, you must configure the iframeEnabled parameter in the generateUrl API.
2. Embedding the Iframe
To integrate the iframe, include it in your HTML using the following structure:
<iframe src="kyc-generated-url-here" allow="autoplay; camera;"></iframe>
3. Event Types and Codes
The iframe emits events to notify the parent application about workflow progress and completion. When the type
is complete
, the code
field provides additional details about the outcome.
Below are the possible values of code
and their corresponding meanings:
Code | Description |
---|---|
DOCUMENT_AUTO_SCAN_TRY_COUNT_EXCEED | The maximum number of document auto-scan attempts has been exceeded. |
DOCUMENT_MANUAL_TRY_COUNT_EXCEED | The maximum number of manual document attempts has been exceeded. |
How to Usetype
andcode
type
andcode
-
Event Type (
type
):- When
type
iscomplete
, the workflow has finished, and you should check thecode
field for details.
- When
-
Event Code (
code
):- Use the
code
value to identify the specific reason for the completion and take appropriate actions.
- Use the
Example Implementation
Here is an example of how to handle type
and code
in your JavaScript application:
window.addEventListener('message', (event) => {
const { type, code } = event.data;
if (type === 'complete') {
switch (code) {
case 'SUCCESS':
console.log('Document Verification complete successfuly.');
break;
case 'DOCUMENT_AUTO_SCAN_TRY_COUNT_EXCEED':
console.warn('Document auto-scan try count exceeded.');
break;
case 'DOCUMENT_MANUAL_TRY_COUNT_EXCEED':
console.warn('Document manual try count exceeded.');
break;
default:
console.info('Unknown completion code:', code);
break;
}
}
});
Updated 13 days ago