Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openTelegramLink crashes Mac OS app. Works fine on mobile and web #30

Open
artem-lazarev opened this issue Nov 13, 2024 · 0 comments
Open
Labels
TG Issue Issue that is related rather to Telegram than to this library

Comments

@artem-lazarev
Copy link

import type { WebApp } from "@twa-dev/types";

function getMiniApp(): WebApp | null {
  if (
    typeof window !== "undefined" &&
    window.Telegram &&
    window.Telegram.WebApp
  ) {
    return window?.Telegram?.WebApp;
  }
  return null;
}

export default function InviteFriends() {

  const app = getMiniApp();
  const shareUrl = encodeURIComponent(`https://t.me/WhalemapBot/app?startapp=${userId}`);
  const telegramUrl = `https://t.me/share/url?url=${shareUrl}`;

  return (
    <div>
      <Button onClick={() => {app.openTelegramLink(telegramUrl))>
        Send
      </Button>
    </div>
  )
}
@ArthurStam ArthurStam added the TG Issue Issue that is related rather to Telegram than to this library label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TG Issue Issue that is related rather to Telegram than to this library
Development

No branches or pull requests

2 participants