skip to Main Content

How I can detect if user is using my web app using telegram web app. I need to show some information if he is.

Thank you!

2

Answers


  1. I’d use the navigator.userAgent property, but this can be easily edited by the user to appear as something else.

    function isUserOnTelegram(){
        return navigator.userAgent.includes('Telegram');
    }
    
    Login or Signup to reply.
  2. Joshua’s answer can work but it is not recommended since the user can easily bypass it.

    The best way is to check if web sockets are available, sin some features are not available on telegram web app.

    This is the code for it:

    const supportsWebRTC = !!window.RTCPeerConnection;
    if (supportsWebRTC) {
      // Likely a regular browser
    } else {
      // May be Telegram web app
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search