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

fix: Update isSupported check for sendData method #680

Merged
merged 3 commits into from
Mar 22, 2025

Conversation

makisukurisu
Copy link
Contributor

Fixes #673

⚠️ Not tested ⚠️

Working under the following assumptions:

  • tgWebAppData is equivalent of WebAppInitData;
  • tgWebAppData is set under the same circumstances as WebAppInitData;
  • sendData method is available for mini-apps running from inline mode.

If tgWebAppData is not processed as WebAppInitData type object is, I suggest to reject this PR.
If tgWebAppData is processed more or less the same, but sendData is not available for inline mode, additional checks would be required, for example:

    isSupported() {
      // tgWebAppData is set only when the app is launched
      // via a keyboard button OR from inline mode
      const isDataSet = launchParams().tgWebAppData !== undefined;
      const isLaunchedFromInline = launchParams().tgWebAppBotInline;
      // Since `sendData` is not available from inline mode, we need to:
      // 1. Ensure we don't have `tgWebAppData`
      // 2. Ensure the app is not launched from inline mode
      return (!isDataSet && !isLaunchedFromInline)
        ? 'The application must be launched via a keyboard button'
        : undefined;
    },

(If I'm not mistaken in the boolean checks 😅)

Copy link

changeset-bot bot commented Mar 9, 2025

🦋 Changeset detected

Latest commit: 503171f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@telegram-apps/sdk Patch
@telegram-apps/sdk-react Patch
@telegram-apps/sdk-solid Patch
@telegram-apps/sdk-svelte Patch
@telegram-apps/sdk-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Mar 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 22, 2025 5:57pm

@makisukurisu
Copy link
Contributor Author

image
From local debugging.

With a setup more or less, like here:
https://docs.python-telegram-bot.org/en/stable/examples.webappbot.html

@heyqbnk
Copy link
Member

heyqbnk commented Mar 22, 2025

The problem here is that in some cases, launching the application via Inline Keyboard Button, Telegram still sends init data. I have checked Telegram SDK and they don't perform any checks here. I assume, we should do the same - disable any additional checks.

@heyqbnk heyqbnk merged commit 0a37101 into Telegram-Mini-Apps:master Mar 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: SendData does not work
2 participants