If you chose to prompt the user on sign in during the configuration step, the user is prompted to approve delegation for your application when they next sign in.
You can use the initDelegationProcess method from the wallets module to open the delegation modal UI:
// Open the delegation modal for all eligible walletstry await DynamicSDK.instance.wallets.initDelegationProcess()// Or specify which wallets to delegatetry await DynamicSDK.instance.wallets.initDelegationProcess( walletIds: ["wallet-id-1", "wallet-id-2"])
You can observe delegation state changes using Combine:
import Combine// Get current state synchronouslylet state = DynamicSDK.instance.wallets.delegatedAccessStateprint("Enabled: \(state.delegatedAccessEnabled ?? false)")print("Required: \(state.requiresDelegation ?? false)")// Listen to state changesvar cancellables = Set<AnyCancellable>()DynamicSDK.instance.wallets.delegatedAccessChanges .sink { state in for wallet in state.walletsDelegatedStatus { print("\(wallet.address): \(wallet.status)") } } .store(in: &cancellables)
// Get status of all walletslet statuses = try await DynamicSDK.instance.wallets.getWalletsDelegatedStatus()for status in statuses { print("Wallet \(status.address) on \(status.chain): \(status.status)")}// Get status for a specific walletif let status = DynamicSDK.instance.wallets.getDelegationStatusForWallet("wallet-id") { print("Status: \(status.status)") // .delegated, .pending, or .denied}
// Dismiss the prompt for the current session only (resets on logout/restart)try await DynamicSDK.instance.wallets.dismissDelegationPrompt()// Or dismiss for a specific wallettry await DynamicSDK.instance.wallets.dismissDelegationPrompt(walletId: "wallet-id")// Permanently deny delegation for a wallet (user won't be prompted again)try await DynamicSDK.instance.wallets.denyWalletDelegation(walletId: "wallet-id")// Clear all session dismissalstry await DynamicSDK.instance.wallets.clearDelegationSessionState()
What's next?
Learn how to properly receive the delegation materials on your server