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

[Bug]: utils.shareURL creates link, which doesn't work correctly inside Telegram app #356

Open
rodnoycry opened this issue Jun 16, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rodnoycry
Copy link

Telegram Application

Telegram for Android, Telegram for iOS, Telegram Desktop

Describe the Bug

shareURL method creates link in the next format:

https://t.me/share?url=<url>

Which should trigger share modal in the app according to official documentation of the Share links API. The thing is - this format works correctly only if link was opened outside of the telegram app, for example this link:

https://t.me/share?url=google.com

Will show share modal after redirecting to the app if was clicked in the web environment. But if you copy this exact link to the Telegram app and send it - the same link will give the next error (tested on Windows Desktop, iOS and Android app):

Username @share not found

This is probably happening because Telegram thinks that t.me/share is actual link to the user with "@share" username, when link in such format used in the Telegram application

The same problem happened when I tried to use shareURL method inside my Telegram Mini App. I got error that user was not found

To make link work you actually need to use this format:

https://t.me/share/url?url=<url>

With the additional /url part. Links in this format behaves correctly, you can check it out both inside and outside of the Telegram app:

https://t.me/share/url?url=google.com

P.S.
Links, that use tg://msg_url variation of links which are also described in docs and looks like this:

tg://msg_url?url=<url>&text=<text>

Work as expected, but it's not possible to use links in this format in Telegram Mini App

To Reproduce

Steps to reproduce the behavior:

  1. Initialize utils
import { initUtils } from '@tma.js/sdk';

const [utils] = initUtils();
  1. Call shareLink method with example link
    utils.shareURL('https://google.com', 'Test message');

Expected Behavior

Opens Telegram app with share modal

@rodnoycry rodnoycry added the bug Something isn't working label Jun 16, 2024
@heyqbnk
Copy link
Member

heyqbnk commented Jun 16, 2024

Thanks for the issue.

We found it not really long time ago. The problem is Telegram has 2 formats of sharing links, both of them doesn't work in some specific Telegram applications.

Related fresh issues:
— Telegram Web K: morethanwords/tweb#327
— Telegram for iOS: TelegramMessenger/Telegram-iOS#1415

@rodnoycry
Copy link
Author

Oh, got it, thank you. Should I also add reproduction in these opened issues?

@heyqbnk
Copy link
Member

heyqbnk commented Jun 17, 2024

No. We are just waiting for the repositories owners to fix the problem

@heyqbnk
Copy link
Member

heyqbnk commented Jun 18, 2024

I have rolled out an update with the link changed, check out @tma.js/[email protected]. Not closing the issue until the Telegram team fixes the problem on their side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@heyqbnk @rodnoycry and others