Open
Description
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.