Last active
February 23, 2018 11:05
-
-
Save JillevdW/b2befcffa67eb713bcc62fd9d028b4c3 to your computer and use it in GitHub Desktop.
webview medium javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addPerson(name, age) { | |
//It's really this simple. We'll call this from the native code. | |
console.log('Name: ' + name + ' Age: ' + age); | |
} | |
function sendNameToNative(name) { | |
//This function will send the name to native. | |
//We can add an EventListener to an object on the page to call this function when it is clicked. | |
try { | |
webkit.messageHandlers.callback.postMessage(name); | |
} catch(err) { | |
console.log('Can not reach native code'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment