WalletConnectSwift icon indicating copy to clipboard operation
WalletConnectSwift copied to clipboard

Connecting to Wallet

Open frankynines opened this issue 4 years ago • 25 comments

Using this SDK

After I call open URL it redirects to the MetaMask then does nothing. Is there a missing step to have it connect and return to the parent app?

frankynines avatar Aug 07 '21 03:08 frankynines

WCURL Has to be encoded. Should add to documentation.

frankynines avatar Aug 09 '21 07:08 frankynines

Can you add to the documentation how this should be done, please...? I am facing the same problem.

j-cimb-barker avatar Aug 10 '21 14:08 j-cimb-barker

Can you add to the documentation how this should be done, please...? I am facing the same problem.

I worked out how to do this. See : https://github.com/WalletConnect/WalletConnectSwift/issues/70

j-cimb-barker avatar Aug 11 '21 14:08 j-cimb-barker

Here you can find information on how to encode universal links: https://docs.walletconnect.org/mobile-linking#for-ios

sche avatar Aug 16 '21 09:08 sche

Hello @j-cimb-barker

I'm facing same problem here. I checked repo be mentioned what you post #70, and implemented it. But issue still existed.

Here's Url what i encoded before using UIApplication.shared.open to open it.

https://metamask.app.link/wc?uri=wc%3AAD5C58F5%2D28D5%2D499B%2DB81F%2DD8C79FE169E8%401%3Fbridge%3Dhttps%253A%252F%252Fj%2Ebridge%2Ewalletconnect%2Eorg%26key%3D726172697479d1ecfd0fa2f16c523fa33fcb887f8c98a0b5919f835298563094

Here's bridge server I used.

https://j.bridge.walletconnect.org

I still hanging in metamash iOS app without popup from bottom which's asking me to connect with. Is this issue caused on encoded url, or bridge server url depends on your experience?

Appreciate it.

peoplewhite avatar Aug 25 '21 10:08 peoplewhite

@peoplewhite It seems that your URL looks fine. Could you try using a different bridge server?

sche avatar Aug 25 '21 11:08 sche

@sche Thanks for checking. 😊

I tried these bridge servers, but fail... Sometimes work, sometimes fail.

https://safe-walletconnect.gnosis.io
https://wcbridge.zerion.io
https://j.bridge.walletconnect.org
https://bridge.walletconnect.org

Would you provide any suggestions?

Do I need to build a "bridge server" for my app?

peoplewhite avatar Aug 26 '21 02:08 peoplewhite

I saw similar issues. Trust wallet worked fine, but Metamask did not respond to any of the bridges I tried

kohlivarun5 avatar Aug 26 '21 14:08 kohlivarun5

@peoplewhite @kohlivarun5 bridge servers might be not very responsive sometimes. If it worked at least once with MetaMask, then the universal link is correct.

sche avatar Aug 26 '21 16:08 sche

Thanks @sche, Do you have any recommendations on how to debug such things? Is creating and running a custom bridge the way to go for it?

kohlivarun5 avatar Aug 26 '21 19:08 kohlivarun5

@kohlivarun5 no need to create a custom bridge. If MetaMask never worked for you, probably you are doing smth wrong. Here is a link to code that works for us with MetaMask, Trust, Rainbow, Ledger Live (other wallets I did not test yet) https://github.com/gnosis/safe-ios/blob/40a50dc8e6b3c007c8b3279cab0c202bef06d4a1/Multisig/UI/Settings/OwnerKeyManagement/WalletConnectOwnerKey/ConnectWalletViewController.swift#L112

sche avatar Aug 26 '21 20:08 sche

Hello @j-cimb-barker

I'm facing same problem here. I checked repo be mentioned what you post #70, and implemented it. But issue still existed.

Here's Url what i encoded before using UIApplication.shared.open to open it.

https://metamask.app.link/wc?uri=wc%3AAD5C58F5%2D28D5%2D499B%2DB81F%2DD8C79FE169E8%401%3Fbridge%3Dhttps%253A%252F%252Fj%2Ebridge%2Ewalletconnect%2Eorg%26key%3D726172697479d1ecfd0fa2f16c523fa33fcb887f8c98a0b5919f835298563094

Here's bridge server I used.

https://j.bridge.walletconnect.org

I still hanging in metamash iOS app without popup from bottom which's asking me to connect with. Is this issue caused on encoded url, or bridge server url depends on your experience?

Appreciate it.

I would suggest building and running the Gnosis Safe App on a Test Device and then looking at how they did it. Generally if you don't get a response from MetaMask it's due to the encoded url not being correct.

j-cimb-barker avatar Sep 01 '21 16:09 j-cimb-barker

Generally if you don't get a response from MetaMask it's due to the encoded url not being correct.

Or due to not enough time to actually send the handshake request to MetaMask before opening it.

sche avatar Sep 01 '21 20:09 sche

I am encountering the same problem, where the URL works and stops working randomly, even using all of the different servers recommended before. Are the servers down? or do they have a limit of requests per device which would case to suddenly stop working without any code changes?

@sche Thanks for checking. 😊

I tried these bridge servers, but fail... Sometimes work, sometimes fail.

https://safe-walletconnect.gnosis.io
https://wcbridge.zerion.io
https://j.bridge.walletconnect.org
https://bridge.walletconnect.org

Would you provide any suggestions?

Do I need to build a "bridge server" for my app?

rndhacker avatar Sep 04 '21 20:09 rndhacker

Actually I still be stuck in this problem.

Sometimes I get wallet address succeed, then be stuck in personal_sign proceed in MetaMask iOS app (with wallet address & nonce message from app server).

I'm wondering why there's no such problem for using Rarible iOS app. Maybe they using their owned bridge server I guess...

Still seeking for solutions here...🙏

peoplewhite avatar Sep 05 '21 08:09 peoplewhite

I think it has to do with the way it works with Metamask. When it wasn't working for Metamask, I tried connecting with Trust Wallet and it was working perfectly.

rndhacker avatar Sep 05 '21 15:09 rndhacker

With Metamask I recommend cleaning open WalletConnect sessions from time to time in advanced settings of mobile MetaMask. If some requests work with MetaMask, but not always, 99% that this is an issue with that MetaMask can not receive your request sometimes. This might happen due to

  • Bridge server is not responsive
  • The mobile app did not have enough time to send a request before opening a MetaMask app. Please check the console that the request was actually sent.

You can try to test similar scenarios with Gnosis Safe App where the code is open source and works well with MetaMask https://github.com/gnosis/safe-ios Also, you can try to connect to MetaMask via a QR code (not a deep link) and to check how it behaves. Here you can use Example apps in the WalletConnectSwift repo.

sche avatar Sep 06 '21 12:09 sche

Hi team, I found that we should wait until the bridge has been connected then we can navigate to the wallet via universal link.

Specifically, wait for this method to be called:

func client(_ client: Client, didConnect url: WCURL)

The bridge I used: https://safe-walletconnect.gnosis.io

duycao2506 avatar Sep 07 '21 06:09 duycao2506

To solve this problem, you need to implement a local bridge server. The Android SDK has a built local server.

mataide avatar Oct 15 '21 11:10 mataide

To solve this problem, you need to implement a local bridge server. The Android SDK has a built local server.

Are you sure? Is this what gnosis safe does? Others say it works just fine in their opensource app

BrettRosen avatar Oct 17 '21 03:10 BrettRosen

After checking out gnosis-safe client implementation, i've figured out two parts of a solution for everyone who got stuck:

Correct way to create universal link (example for metamask, similar idea works with trust, but Rainbow wallet is not working) URL(string: "https://metamask.app.link/wc?uri=\(wcURL.absoluteString.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? "")")

For Rainbow client you shoud use .controlCharacters instead: URL(string: "https://rnbwapp.com/wc?uri=\(wcURL.absoluteString.addingPercentEncoding(withAllowedCharacters: .controlCharacters) ?? "")")

Best bridge: https://safe-walletconnect.gnosis.io walletconnect bridges are not responding at the time of writing.

Everything here is relevant for 1.6.0 client, and may not work in 2.0 client

elrid avatar Nov 04 '21 17:11 elrid

works great with @elrid solution!

sotrosh avatar Dec 10 '21 03:12 sotrosh

Thank you! @elrid

tommychavez avatar Dec 27 '21 06:12 tommychavez

.

ahumay avatar Feb 08 '22 16:02 ahumay

@ahumay check out OpenSea mobile app, it's there but not sure what libs they use. I know it's written with Flutter though

DmitryBespalov avatar Feb 08 '22 19:02 DmitryBespalov