WEB3DEV's Recent Forum Activity

  • unfortunately this did not help, perhaps someone from the construct team can answer this question? The thing is that I tried all sorts of methods, and I can neither copy at the click of a button while in the game inside the telegram web app, nor call the modal window "share" to share the link to the game among the chat telegram. I'm confused.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello!

    I am creating an HTML5 game using Construct 3 and want to implement a function to copy a referral code to the clipboard when the "Invite" button is clicked in a Telegram Mini App. Here is the code I am using:

    javascript

    const refCode = "YOUR_REFERRAL_CODE";
    
    function copyToClipboard(text) {
     const tempInput = document.createElement("textarea");
     tempInput.value = text;
     document.body.appendChild(tempInput);
     tempInput.select();
     document.execCommand("copy");
     document.body.removeChild(tempInput);
    }
    
    if (Telegram.WebApp) {
     copyToClipboard(refCode);
     Telegram.WebApp.showAlert("Referral code copied to clipboard!");
    } else {
     alert("Referral code copied to clipboard!");
    }
    

    This code works in the browser (Google Chrome), but it does not work in the Telegram Mini App window. When the button is clicked, nothing happens. How can I correctly implement text copying to the clipboard within the Telegram Mini App? Thank you in advance!

WEB3DEV's avatar

WEB3DEV

Member since 14 Jun, 2024

None one is following WEB3DEV yet!

Trophy Case

  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

3/44
How to earn trophies