ioPay Docs
  • Welcome to ioPay Docs
  • 💜IoTeX & Ethereum & Polygon & BNB
  • 💙Solana
  • 🧡BitCoin
  • Developer Guides
    • Web Dapps Development
    • Deep linking
    • Native Mobile Web3 Apps
      • iOS
      • Android
    • Abstract Account Wallet
      • userop-swift (iOS)
      • userop-kotlin (Android)
    • ioPay x dApps Co-promotions Program
  • User Guides
    • Crypto Handle & Custom Domain Setup
  • How to withdraw IOTX from centralized exchanges (Binance)?
  • Walletconnect - iOS
  • Rainbow Kit
Powered by GitBook
On this page
  • What is deep linking?
  • How to open your dapp in ioPay with deep link?
  1. Developer Guides

Deep linking

What is deep linking?

Deep linking does this by specifying a custom URL scheme (iOS Universal Links) or an intent URL (on Android devices) that opens your app if it’s already installed. Deep links can also be set to direct users to specific events or pages, which could tie into campaigns that you may want to run.

IoPay supports deep link below to open your pages in ioPay dapp browser :

iopay://io.iotex.iopay/open?action=web&url={{URL}}

How to open your dapp in ioPay with deep link?

export const helper = {
  isPc() {
    const userAgentInfo = global?.navigator?.userAgent;
    const Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
    let flag = true;
    for (let v = 0; v < Agents.length; v++) {
      if (userAgentInfo.indexOf(Agents[v]) > 0) {
        flag = false;
        break;
      }
    }
    return flag;
  },
  // check the dapp is in a mobile system browser
  checkEnv() {
    const isPc = this.isPc()
    const isBrower =  typeof window === 'undefined' ? false : true
    const isIopayMobile = window?.navigator?.userAgent && (window?.navigator?.userAgent.includes('IoPayAndroid') || window?.navigator?.userAgent.includes('IoPayiOs'))
    console.log('isBrower', isBrower, 'isIopayMobile' , isIopayMobile)
    if (!isPc) {
      if(isBrower && isIopayMobile) {
        return true
      } else if (isBrower && !isIopayMobile) {
        this.openDeepLink()
        return false
      }
    }
    return true;
  },
  //open the dapp with ioPay deep linking
  openDeepLink() {
    const a = document.createElement("a");
    const tagId = "startIoPay";
    a.setAttribute("href", `iopay://io.iotex.iopay/open?action=web&url=${window.location.href}`);
    a.setAttribute("id", tagId);
    if (document.getElementById(tagId)) {
      // @ts-ignore
      document.body.removeChild(document.getElementById(tagId));
    }
    document.body.appendChild(a);
    a.click();
    setTimeout(() => {
      window.location.href = 'https://iopay.me/'
    }, 4000)
  }
}

PreviousWeb Dapps DevelopmentNextNative Mobile Web3 Apps

Last updated 8 months ago