Documentation Index
Fetch the complete documentation index at: https://mintlify.com/frol/near-connect-ios/llms.txt
Use this file to discover all available pages before exploring further.
Overview
WalletBridgeSheet is a ready-to-use SwiftUI view component that presents the wallet connection interface as a full-screen modal sheet. It handles the complete wallet interaction flow including connection, transaction approval, and message signing.
This component automatically manages the wallet WebView lifecycle and displays a loading indicator while the bridge is initializing.
Declaration
Usage
PresentWalletBridgeSheet using .fullScreenCover bound to NEARWalletManager.showWalletUI:
Features
Automatic Flow Management
The sheet automatically handles different wallet interaction flows:- Wallet Connection: When user initiates connection via
walletManager.connect() - Transaction Signing: When transactions need approval
- Message Signing: When messages need to be signed
- Connect & Sign: Combined connection and message signing flow
Loading State
While the wallet bridge is initializing, the sheet displays a loading indicator with the message “Loading wallet connector…”:Close Button
A close button (X icon) is positioned in the top-right corner, allowing users to cancel the wallet interaction at any time. This setswalletManager.showWalletUI to false and triggers cleanup.
Environment Requirements
WalletBridgeSheet requires NEARWalletManager to be available in the SwiftUI environment:
Example
Here’s a complete example from the NEAR Connect demo app:Implementation Details
Initialization
NEARWalletManager.
Lifecycle Hooks
- onAppear: Triggers pending wallet flows when the bridge is ready
- onDisappear: Calls
walletManager.cleanUpOnDismiss()to clean up resources - onChange(isBridgeReady): Monitors bridge initialization state
Pending Flow Handling
The sheet checks for pending operations when the bridge becomes ready:- Sign Message Flow: If
pendingSignMessageParamsexists, triggerstriggerConnectWithSignMessage() - Standard Connection: If
pendingConnectis true, triggerstriggerWalletSelector()
A 0.3-second delay is added before triggering flows to ensure the WebView is fully rendered and ready to receive JavaScript calls.
Related
- NEARWalletManager - Main wallet manager class
- Wallet Connection - Connect wallets guide
- Sending NEAR - Send transactions guide
- Message Signing - Sign messages guide