Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI]: Getting "Connection Declined" from TonConnectUI when connecting to Android Wallets, #267

Open
1 task done
johnifegwu opened this issue Oct 10, 2024 · 0 comments
Open
1 task done
Assignees
Labels
question Further information is requested

Comments

@johnifegwu
Copy link

johnifegwu commented Oct 10, 2024

Your Question

Getting "Connection Declined" from TonConnectUI when connecting to Android Wallets, but connecting to Broser Extension Works fine. What could be wrong?

Context

In my project I'm providing a way for the user to connect to their wallet Browser, Android or iOS using TonConnectUI.

What have you tried so far?

I have looked the Manifest.json just to confirm that everything is alright with it and it appear so.

Relevant Code or Commands

async function initializeTonConnectUI() {
    try {
        tonConnectUI = new TON_CONNECT_UI.TonConnectUI({
            manifestUrl: 'https://[<MY URL>]/tonconnect-manifest.json',
            walletsListConfiguration: {
                //Customize the displayed wallet list
                includeWallets: [
                    {
                        name: "Bitget Wallet",
                        appName: "bitgetTonWallet",
                        imageUrl:
                            "https://raw.githubusercontent.com/bitkeepwallet/download/main/logo/png/bitget%20wallet_logo_iOS.png",
                        universalLink: "https://bkcode.vip/ton-connect",
                        bridgeUrl: "https://bridge.tonapi.io/bridge",
                        platforms: ["ios", "android", "chrome"],
                    },
                ],
            }
        });
        //Change options if needed
        tonConnectUI.uiOptions = {
            language: "en"
        };
        console.log("TonConnectUI initialized successfully.");
    } catch (error) {
        console.error("Error initializing TonConnectUI:", error);
    }
}
async function connectWallet() {
    try {
        if (!tonConnectUI) {
            walletStatus.innerHTML = "TonConnectUI not initialized.";
            return;
        }

        const currentIsConnectedStatus = tonConnectUI.connected;

        if(currentIsConnectedStatus){
            await tonConnectUI.disconnect(); // disconnect any previously connected wallet
        }

        await tonConnectUI.connectWallet();

        const currentAccount = tonConnectUI.account;
        tonWallet = true;
        const address = new TonWeb.utils.Address(currentAccount.address);
        walletAddress = address.toString(isUserFriendly = true);
        walletStatus.innerHTML = `Wallet connected: ${walletAddress}`;

        // Get user's last transaction hash using tonweb
        const lastTx = (await tonweb.getTransactions(address, 1))[0]
        // we use if in case of new wallet.
        if(lastTx){
            lastTxHash = lastTx.transaction_id.hash
        }
        validateBuyNowButton();
    } catch (error) {
        console.error("Failed to connect wallet:", error);
        walletStatus.innerHTML = `Failed to connect wallet.\n${error}`;
    }
}

// Manifest

{
    "url": "https://[<MY URL>]",
    "name":  "MY APP NAME",
    "iconUrl": "https://[<MY URL>]/paydayicon.png",
    "termsOfUseUrl": "https://[<MY URL>]/terms.html",
    "privacyPolicyUrl": "https://[<MY URL>]/privacy.html"
}

Documentation Check

  • Yes, I have checked the documentation.
@johnifegwu johnifegwu added the question Further information is requested label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants