maurovz / Swift-WalletConnect

Easy iOS Web3 connection for MetaMask, TrustWallet and Rainbow Wallet
Apache License 2.0
59 stars 16 forks source link

Keep connection stage #21

Open thandang opened 1 year ago

thandang commented 1 year ago

Thanks for the project. I found that there is no storage on connection. Which means if I connected. Kill the app and open again, the connection session is lost. Can we keep it?

Thanks in advance.

Eunno-An commented 1 year ago

I solved this issue using AppStorage(Local DB).

maurovz commented 1 year ago

Thanks for the question and the reply. @Eunno-An Could you give us an example so maybe I could add it to the package?

@thandang We are using WalletConnect V1 so possibly this is a feature that you need to request in their repo https://github.com/WalletConnect/WalletConnectSwift

Eunno-An commented 1 year ago

@thandang @maurovz Sorry for checking late.My solution is simple.

I will introduce LoginView first.

@AppStorage("walletAddress") var address: String = UserDefaults.standard.string(forKey: "walletAddress") ?? ""

Check "walletAddress" using if - else.

image

and inside the WalletButtonView code block, write below code in success code block.

address = user.wallet.address
image

And Secondly, logoutButton onTapGesture, init address tag in localDB.

image

If you have any questions, please feel free to ask. As much as I have been helped, I hope to help others as well.

Eunno-An commented 1 year ago

Another Strategy is Using AWS Cognito service. You can use wallet address to nickname that cannot be duplicated.

Thank you

maurovz commented 1 year ago

@thandang @maurovz Sorry for checking late.My solution is simple.

I will introduce LoginView first.

@AppStorage("walletAddress") var address: String = UserDefaults.standard.string(forKey: "walletAddress") ?? ""

Check "walletAddress" using if - else. image

and inside the WalletButtonView code block, write below code in success code block.

address = user.wallet.address
image

And Secondly, logoutButton onTapGesture, init address tag in localDB. image

If you have any questions, please feel free to ask. As much as I have been helped, I hope to help others as well.

I will try to test this. Thanks!

maurovz commented 1 year ago

Another Strategy is Using AWS Cognito service. You can use wallet address to nickname that cannot be duplicated.

Thank you

I'd prefer people are not dependant on more 3rd party services. At the same time, we could add optional sub packages in the future.

thandang commented 1 year ago

What I did is stored the session whenever it's connected. We might have more than one sessions. So, the key should be send from the app as parameter instead of sdk. Whenever user launch the app (like first open or kill, open again), we will check and reconnect.

Eunno-An commented 1 year ago

Another Strategy is Using AWS Cognito service. You can use wallet address to nickname that cannot be duplicated. Thank you

I'd prefer people are not dependant on more 3rd party services. At the same time, we could add optional sub packages in the future.

Thanks to reply But AppStorage solution have serious problem some cases. If i edit the wallet address in my local file, and using this glaip package for another service, the result might be wrong.

So , like AWS Cognito, 3rd party service should be needed especially keeping session issue. Thanks