After logging to a mobile device by WalletConnect, I use the Moralis transfer function, and this must be confirmed in the Trust wallet app or in the MetaMask app. Everything works perfectly, But I can’t find a solution for redirecting automatically in Trust Wallet App To confirm this transaction. ( I am Using Mobile WalletConnect Links ).
script.js
/* Moralis init code */
const serverUrl = "****************************************";
const appId = "****************************************";
Moralis.start({ serverUrl, appId });
/* Authentication code */
async function walletConect() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
provider: "walletconnect",
chainId: 56,
signingMessage: "Welcome"
}).then(function (user) {
})
.catch(function (error) {
});
}
}
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "hidden") {
window.localStorage.removeItem("WALLETCONNECT_DEEPLINK_CHOICE");
}
});
//Logout current session
async function logOut() {
await Moralis.User.logOut();
}
//Buy Nft
async function buyNFT() {
const data1 = {type: "native", amount: Moralis.Units.ETH("0.0001"), receiver: "****************************************"}
let result = await Moralis.transfer(data1)
TrackJS.track(result);
console.log(result)
}
document.getElementById("wallet-connect").onclick = walletConect;
document.getElementById("btn-logout").onclick = logOut;
document.getElementById("buy-nft").onclick = buyNFT;