Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
543 stars 133 forks source link

[Feature]: add shareToStory #432

Open daniilshamraev opened 1 month ago

daniilshamraev commented 1 month ago

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

add shareToStory

Describe alternatives you've considered

No response

Additional context

No response

heyqbnk commented 1 month ago

To be implemented in a new package major version. I am not sure there are clients supporting Mini Apps v7.8 now, so this method will not even work

awerc commented 1 month ago

My client supports v7.8, and I have already seen a mini apps that utilizes shareToStory feature. Therefore, it would be great to release it sooner, because I can't use it without downloading the native SDK along with @telegram-apps/sdk @heyqbnk

image
agudulin commented 1 month ago

@awerc here's how you can use it:

import { postEvent } from "@telegram-apps/sdk-react";

postEvent("web_app_share_to_story" as any, {
  media_url: 'image.png',
  text: text.slice(0, 2048),
  widget_link: {},
});
XantreDev commented 1 month ago

Here is typesafe way

interface CreateParams<
  Params = never,
  VersionedParam extends UnionKeys<Params> = never,
> {
  params: Params;
  versionedParams: VersionedParam;
}
declare module "@telegram-apps/sdk" {
  interface MiniAppsMethods {
    web_app_share_to_story: CreateParams<WepAppShareStory>;
  }
}

type WepAppShareStory = {
  media_url: string;
  text?: string;
  widget_link?: {
    url: string;
    name?: string;
  };
}
hieutvIcetea commented 3 weeks ago

@awerc here's how you can use it:

import { postEvent } from "@telegram-apps/sdk-react";

postEvent("web_app_share_to_story" as any, {
  media_url: 'image.png',
  text: text.slice(0, 2048),
  widget_link: {},
});

This method is not working for me, the console don't throw any error just the post event. Is there something I need to do to make this work?

EnettyTech commented 2 weeks ago

@awerc here's how you can use it:

import { postEvent } from "@telegram-apps/sdk-react";

postEvent("web_app_share_to_story" as any, {
  media_url: 'image.png',
  text: text.slice(0, 2048),
  widget_link: {},
});

This method is not working for me, the console don't throw any error just the post event. Is there something I need to do to make this work?

https://github.com/lumoscompany/bilft.com/blob/7e1b46dfa1d1dcf2b442a84ff04187fd912d822f/source/features/PagesLayout.tsx#L43 Follow this file make working for me.