TONTONDocs
Android

How to inject TON's WalletKit into WebView on Android platform

Initialize the WalletKit before injecting it into WebView. See the initialization guide for details.

Injecting WalletKit into WebView allows integrating the wallet service with a dApp running in a native WebView and handling its events.

To do so, enable JavaScript in the WebView and inject TonConnect.

import android.webkit.WebView
import io.ton.walletkit.ITONWalletKit
import io.ton.walletkit.extensions.injectTonConnect

val webView = WebView(context)
webView.settings.javaScriptEnabled = true

webView.injectTonConnect(walletKit)
webView.loadUrl(/* dApp URL */)

After the injection is complete, handle dApp events from a custom events handler.

Last updated on