1

I am using walletconnect_dart pkg in flutter to connect to metamask and trustwallet application. But when clicking on the button, i have to choose between trustwallet and metamask. I want when i click MM btn it redirect to mm and the same with trustwallet.

     final connector = WalletConnect(
      bridge: 'https://bridge.walletconnect.org',
      clientMeta: const PeerMeta(
          name: 'Nika',
          description: 'An app for converting pictures to NFT',
          url: 'https://nikaguru.page.link/start',
          icons: [
            'https://files.gitbook.com/v0/b/gitbook-legacy-files/o/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
          ]));

  var _session, _uri;

  loginUsingMetamask(BuildContext context) async {
    try {
      print(connector);
      var session = await connector.createSession(onDisplayUri: (uri) async {
        _uri = uri;
        print(uri);
        await launchUrlString(uri, mode: LaunchMode.externalApplication);
      });
      addr = session.accounts[0];
      print(session.accounts[0]);
      print(session.chainId);
      setState(() {
        _session = session;
      });
    } catch (exp) {
      print(exp);
    }
  }

1 Answer 1

0

Hey sorry if this is late hope this helps what you can do is add "deep-links" of your respective apps while creating a session

i have tested this on android...

e.g.

Future<void> _launchOnlyMetaMaskWallet()async{
  final session = await connector.createSession(
        chainId: chainId,
        onDisplayUri: (uri) async {
          debugPrint("----> URL ---> $uri");
          String metamaskURL = "metamask://wc?uri=$uri";
          String trustwalletURL = "trust://wc?uri=$uri";
          String rainbowURL = "rainbow://wc?uri=$uri";

          try {
            await launchUrl(Uri.parse(metamaskURL), mode: LaunchMode.externalNonBrowserApplication);
          } catch (err) {
            debugPrint("error on launch --> $err");
            await launchStoreUrl();
          }
        },
      );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.