To establish a connection with a dApp, one needs a connection request URL from any source: copy/paste, QR code, deep link, etc. Send it to the WalletKit to initiate a connection request.
Once the connection request is fired, the corresponding event will be sent to your event handler. The connection event contains an object you can use to display request information to your app’s users and to approve (or reject) the request to complete connection establishment.
Copy
Ask AI
class YourCustomWalletEventsHandler: TONBridgeEventsHandler { func handle(event: TONWalletKitEvent) throws { switch event { case .connectRequest(let request): // Send request object to appropriate screen // to display request information to app user break default: () } }}// Call an appropriate method corresponding to the user's response// To approvetry await request.approve(walletAddress: /* TON wallet address */)// To rejecttry await request.reject(reason: /* rejection reason */)
After approval, the connection will be established, and the wallet service will be able to receive and handle other events associated with the corresponding TON wallet.
All event handling is made through a custom event handler.Received events carry a lot of useful information that can be displayed to the user to allow them to approve or reject the request based on their action.The only exception is a disconnection request. Even though it contains information you can show to a user, there is no need to approve or reject it on their end.
class YourCustomWalletEventsHandler: TONBridgeEventsHandler { func handle(event: TONWalletKitEvent) throws { switch event { case .transactionRequest(let request): // Send request object to appropriate screen // to display request information to app user break default: () } }}// Call an appropriate method corresponding to the user's response// To approvetry await request.approve()// To rejecttry await request.reject(reason: /* rejection reason */)
class YourCustomWalletEventsHandler: TONBridgeEventsHandler { func handle(event: TONWalletKitEvent) throws { switch event { case .signDataRequest(let request): // Send request object to appropriate screen // to display request information to app user break default: () } }}// Call an appropriate method corresponding to the user's response// To approvetry await request.approve()// To rejecttry await request.reject(reason: /* rejection reason */)
class YourCustomWalletEventsHandler: TONBridgeEventsHandler { func handle(event: TONWalletKitEvent) throws { switch event { case .disconnect(let info): // Send info object to appropriate screen // to display request information to app user break default: () } }}
Alternatively, explore the complete demo wallet with WalletKit integration: