Created
May 27, 2019 14:41
-
-
Save apuravchauhan/06f5984b767264ff1e2d058530a7fb2c to your computer and use it in GitHub Desktop.
HTML page calling JS bridge methods forwarding to native UPI calls
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="author" content="Apurav Chauhan"> | |
<meta name="title" content="Web to android interaction"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<style> | |
div { | |
margin: 5px; | |
} | |
.box{background: #f0f0f0;padding: 25px;} | |
</style> | |
</head> | |
<body style="padding:25px"> | |
<h2 class="box"> | |
Web + Android UPI Apps | |
<hr> | |
<a style="font-size:12px" href="https://twitter.com/apuravchauhan">@apuravchauhan</a> | |
</h2> | |
<hr> | |
<br> | |
<div id="upi"></div> | |
<script type="text/javascript"> | |
window.onload = loadUPIHandlers; | |
function loadUPIHandlers() { | |
var a = ApuSDK.upiHandlers(); | |
var upiList = a.length == 0 ? [] : a.split(","); | |
var dom = ""; | |
if (upiList.length == 0) { | |
dom = '<div class="box">No UPI Apps found on phone.</div>'; | |
} else { | |
for (var i = 0; i < upiList.length; i++) { | |
var info = upiList[i].split("|"); | |
dom += '<div onClick="openUPI(\'' + info[0] + '\',\'' + info[1] + '\')"><h4><a href="javascript:void(0)">' + info[0] + '</a></h4></div>'; | |
} | |
} | |
document.getElementById("upi").innerHTML = dom; | |
} | |
function openUPI(package, activity) { | |
ApuSDK.openUPIHandler(package, activity) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment