Skip to content

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

@artem-lazarev

Description

@artem-lazarev
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>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    TG IssueIssue that is related rather to Telegram than to this library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions