Skip to content

Instantly share code, notes, and snippets.

@niksumeiko
Created May 16, 2017 10:15
Show Gist options
  • Save niksumeiko/628e965ebe5d38e303892deffaa40172 to your computer and use it in GitHub Desktop.
Save niksumeiko/628e965ebe5d38e303892deffaa40172 to your computer and use it in GitHub Desktop.
Sending data from webView to native Android/iOS layer in hybrid mobile app
function sendToNative(data: string) {
if (/android/i.test(window.navigator.userAgent)) {
if (window.quicketNative) {
return window.quicketNative.send(data);
}
}
let frame = document.createElement('iframe');
frame.width = '100';
frame.height = '1';
frame.src = `quicketNative:send:${encodeURIComponent(data)}`;
document.body.appendChild(frame);
document.body.removeChild(frame);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment