Web View Page Examples
Web View Page Example:
<html>
<head>
<title>Web view step1</title>
<script>
function sendToApp(msg) {
try {
const appWnd = nativeExecution;
appWnd.postMessage(JSON.stringify(msg));
} catch (e) {
console.log('it is not mobile app view or we lost context!');
}
}
function successHandler() {
console.log("Success");
sendToApp({
result: 'success',
parameters: [{name: 'param1', value: 'Bob'}, {name: 'param2', value: '42'}]
});
}
function failHandler() {
console.log("Fail");
sendToApp({
result: 'error',
errorMessage: 'We can not finish web view step'
});
}
</script>
</head>
<body>
<div style="padding-top: 64px"></div>
<button onclick="successHandler()" style="width: 150px; height: 64px">Click me for success!</button>
<div style="padding-top: 64px"></div>
<button onclick="failHandler()" style="width: 150px; height: 64px">Click me for fail!</button>
</body>
</html>
The format of the callback should be like in the example:
{
result: 'success',
parameters: [{name: 'param1', value: 'Bob'}, {name: 'param2', value: '42'}] // optional if you want to pass parameters back through the interaction extension webhook as self attested credential
}
or
{
result: 'error',
errorMessage: 'We can not finish web view step' // Error message to show to the user in the app
}