Closed MohamedBassem closed 6 months ago
👋 That's sounds like a good idea !
You mean something like this :
type ShareIntent = {
files: ...;
text: string | null;
type: "text" | "url" | null;
};
what about this :
type ShareIntent = {
files: ...;
text: string | null;
link: string | null;
};
under the hood i only have this information on iOS, it's always a text on android. so for compatibility reason i have to do a manual check with something like that
const link: string | undefined = first(
text?.match(/[(http(s)?)://(www.)?-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/gi),
);
if (!link || !link?.startsWith('http')) {
console.log('wrong link:', link, text);
} else {
console.log('text contain a link', link)
}
for example when you share a link from the amazon app it comes with some text before the real url, so we need to isolate the information.
The better way to add this feature is to have text
(with raw data) and link
return by the hook :
const { shareIntent } = useShareIntent();
console.log(shareIntent.text); // "Hello, click on my link http://example.com"
console.log(shareIntent.link); // "http://example.com"
Alright, it's on my TODO :)
First of all, thanks for the plugin, it was crucial for an app that I'm building!
I have a feature request. It seems that when the intent either contains a
WebURL
or atext
, both end up in theShareIntent
in the text field. Can we maybe add atype
union field in the share intent that contains the original intent type? Thanks!