Skip to content
This repository was archived by the owner on Jan 10, 2026. It is now read-only.
This repository was archived by the owner on Jan 10, 2026. It is now read-only.

Error connecting and handling sessions in the WalletConnect SDK #161

@tieugame2110

Description

@tieugame2110

After I use the mobile device to scan the QR code, it only closes the modal but does not execute the OnAfterConnect function

Expected behavior
after scan QR Code, the WalletConnect.Instance.ActiveSessionChanged function will be executed
note*: i unchecked ResumeSessionOnInit boolean

Screenshots
image

My Code

private void Start()
        {
            //Application.targetFrameRate = Screen.currentResolution.refreshRate;

            // When WalletConnectModal is ready, enable buttons and subscribe to other events.
            // WalletConnectModal.SignClient can be null if WalletConnectModal is not ready.
            WalletConnectModal.Ready += (sender, args) =>
            {
                //// SessionResumed is true if Modal resumed session from storage
                if (args.SessionResumed)
                {
                    OnAfterConnect();
                    Debug.Log(1);
                }
                else
                {
                    OnAfterDisconnect();
                    Debug.Log(2);
                }

                // Invoked after wallet connected
                WalletConnect.Instance.ActiveSessionChanged += (_, @struct) =>
                {
                    if (string.IsNullOrEmpty(@struct.Topic))
                        return;

                    Debug.Log($"[WalletConnectModalSample] Session connected. Topic: {@struct.Topic}");
                    OnAfterConnect();
                    Debug.Log(3);
                };

                // Invoked after wallet disconnected
                WalletConnect.Instance.SessionDisconnected += (_, _) =>
                {
                Debug.Log($"[WalletConnectModalSample] Session deleted.");
                OnAfterDisconnect();
                Debug.Log(4);
            };
        };
    }

    private void OnAfterConnect()
    {
        var UWM = UIWalletManager.Instance;
        var address = GetAddress();
        UWM.web3Manager.userAddress = address;
        UWM.screenManager.ShowScreen("HOME");
        UWM.web3Manager.loginWith = LoginWith.WCModal;
        Debug.Log(address);
    }

    private void OnAfterDisconnect()
    {
        WalletConnectModal.Disconnect();
    }

Environment

  • OS: Android
  • Unity version 2022.3.5f1
  • Package name and version: WalletConnectUnity Modal v1.0.6

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions