Skip to content

Instantly share code, notes, and snippets.

@agustinsivoplas
Created February 14, 2017 15:59
Show Gist options
  • Save agustinsivoplas/af7cca40850287736b1b3f94d3919f63 to your computer and use it in GitHub Desktop.
Save agustinsivoplas/af7cca40850287736b1b3f94d3919f63 to your computer and use it in GitHub Desktop.
<html>
<body>
</br>
</br>
<p>Communication Test</p>
<input type="button" value="Send Token" onclick="__external.postMessage('sendToken', 'ajkdshaskj8979867');"/>
<input type="button" value="Set Cart Items" onclick="__external.postMessage('setCartItemsNumber', '2');"/>
</body>
<script>
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
}
};
var __external = {
postMessage: function(messageType, params) {
if(isMobile.Android()) {
Android.postMessage(messageType, params);
}
if(isMobile.iOS()) {
window.webkit.messageHandlers[messageType].postMessage(params);
}
}
};
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment