JavaScript bridge on a WebView that loads untrusted URLs
The activity loads whatever URL arrives in its intent, with a JavaScript interface attached. Any page it's pointed at can call into your wallet code.
26 webView.settings.javaScriptEnabled = true 27 webView.addJavascriptInterface(WalletBridge(), "wallet") 28 webView.loadUrl(intent.getStringExtra("url")!!)
Whoever sends the link gets the bridge.
26 val url = intent.getStringExtra("url")?.toUri() 27 if (url?.scheme != "https" || url.host !in TRUSTED_HOSTS) return finish() 28 webView.settings.javaScriptEnabled = true 29 webView.addJavascriptInterface(WalletBridge(), "wallet") 30 webView.loadUrl(url.toString())
Only your own pages get the bridge.