RootSoft / walletconnect-dart-sdk

Open protocol for connecting dApps to mobile wallets with QR code scanning or deep linking.
MIT License
104 stars 61 forks source link

WalletConnect integration does not show 'Connect' button on iOS #103

Closed ioridev closed 1 year ago

ioridev commented 1 year ago

Hello,

I am developing a Flutter application that utilizes WalletConnect to interface with the MetaMask wallet. The functionality works as expected on Android devices: when I attempt to create a new session, it redirects to the MetaMask app and shows a 'Connect' button that the user can press to establish the connection.

However, when I test the same functionality on iOS devices, it does not show the 'Connect' button after redirecting to the MetaMask app. The user is unable to establish a connection due to this issue.

Here is the relevant code snippet I am using to create the WalletConnect instance and session:

WalletConnect connector = WalletConnect(
  bridge: 'https://bridge.walletconnect.org',
  clientMeta: const PeerMeta(
    name: 'TestApp',
    description: 'TestApp',
    url: 'https://example.com',
    icons: [
      'https://files.gitbook.com/v0/b/gitbook-legacy-files/o/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media'
    ],
  ),
);

Future<void> loginUsingMetamask(BuildContext context) async {
  if (!connector.connected) {
    try {
      final session = await connector.createSession(
        onDisplayUri: (uri) async {
          _uri = uri;
          await launchUrlString(uri, mode: LaunchMode.externalApplication);
        },
      );
      debugPrint(session.accounts[0]);
      debugPrint(session.chainId.toString());
      setState(() {
        _session = session;
      });
    } catch (exp) {
      debugPrint(exp.toString());
    }
  }
}

I have ensured that both the MetaMask app and the WalletConnect library in my project are updated to their latest versions. Could you provide some insight into why the 'Connect' button is not showing on iOS and how I could resolve this issue?

Thank you in advance for your assistance.

ioridev commented 1 year ago

https://github.com/MetaMask/metamask-mobile/issues/6387

this may be the cause

ioridev commented 1 year ago

https://github.com/MetaMask/metamask-mobile/issues/6457

wufd commented 1 year ago

try

// "mobile": {"native": "metamask:", "universal": "https://metamask.app.link"},

final universalUrl  = "https://metamask.app.link";
final connectUrl = "$universalUrl/wc?uri=${Uri.encodeComponent(uri)}"
launchUrl(Uri.parse(connectUrl), mode: LaunchMode.externalNonBrowserApplication)
ioridev commented 1 year ago

try

// "mobile": {"native": "metamask:", "universal": "https://metamask.app.link"},

final universalUrl  = "https://metamask.app.link";
final connectUrl = "$universalUrl/wc?uri=${Uri.encodeComponent(uri)}"
launchUrl(Uri.parse(connectUrl), mode: LaunchMode.externalNonBrowserApplication)

It does not work in my app. Does it work in your app?

wufd commented 1 year ago

try

// "mobile": {"native": "metamask:", "universal": "https://metamask.app.link"},

final universalUrl  = "https://metamask.app.link";
final connectUrl = "$universalUrl/wc?uri=${Uri.encodeComponent(uri)}"
launchUrl(Uri.parse(connectUrl), mode: LaunchMode.externalNonBrowserApplication)

It does not work in my app. Does it work in your app?

For me it worked

ioridev commented 1 year ago

try

// "mobile": {"native": "metamask:", "universal": "https://metamask.app.link"},

final universalUrl  = "https://metamask.app.link";
final connectUrl = "$universalUrl/wc?uri=${Uri.encodeComponent(uri)}"
launchUrl(Uri.parse(connectUrl), mode: LaunchMode.externalNonBrowserApplication)

It does not work in my app. Does it work in your app?

For me it worked

Nice! Is the Metamask app you have installed the latest version?

wufd commented 1 year ago

try

// "mobile": {"native": "metamask:", "universal": "https://metamask.app.link"},

final universalUrl  = "https://metamask.app.link";
final connectUrl = "$universalUrl/wc?uri=${Uri.encodeComponent(uri)}"
launchUrl(Uri.parse(connectUrl), mode: LaunchMode.externalNonBrowserApplication)

It does not work in my app. Does it work in your app?

For me it worked

Nice! Is the Metamask app you have installed the latest version?

is latest. Maybe the next version of metamask will support walletconnect v2. https://github.com/MetaMask/metamask-mobile/pull/6547
So you can start working on supporting v2

Igormikheev commented 1 year ago

@ioridev Did you manage to solve the problem?

ioridev commented 1 year ago

@Igormikheev Yea! Metamask update solved the problem!