I am using walletconnect_dart to connect my app to Metamask. Scanning the QR code or mobile deep link all works well and is immediately connected to the wallet.
The issue I am facing is that when I restart the app, my wallet is no longer connected to the app. Every time I have to reconnect my wallet to the application with a deep link/QR code.
Is there any way to stay connected to the wallet even after restarting the app?
This is how I am connecting to the wallet
final connector = WalletConnect(
bridge: 'https://bridge.walletconnect.org',
clientMeta: const PeerMeta(
name: 'WalletConnect',
description: 'WalletConnect Developer App',
url: 'https://walletconnect.org',
icons: [
'https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
],
),
);
// Subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_update', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));
// Create a new session
if (!connector.connected) {
final session = await connector.createSession(
chainId: 4160,
onDisplayUri: (uri) {
launchUrl(Uri.parse(uri));
},
);
print(session);
}