react-native-google-recaptcha-v3
Version:
Minimal implementation of Google Recaptcha V3 in React Native Webview
41 lines (34 loc) • 838 B
JavaScript
const recaptchaHtml = `
<html>
<head>
<style>
body {
display: flex;
justify-content: left;
align-items: top;
}
</style>
</head>
<body>
<div id="inline-badge"></div>
<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=onRecaptchaLoadCallback"></script>
<script>
function onRecaptchaLoadCallback() {
var clientId = grecaptcha.render('inline-badge', {
'sitekey': '[SITEKEY]',
'badge': 'inline',
'size': 'invisible'
});
grecaptcha.ready(function () {
grecaptcha.execute(clientId, {
action: 'verify'
})
.then(function (token) {
window.ReactNativeWebView.postMessage(token, '*')
});
});
}
</script>
</body>
</html>`;
export default recaptchaHtml;