-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
DOM lib: add support for navigator.share #18642
DOM lib: add support for navigator.share #18642
Comments
This does not seem to have a spec yet. we only include definitions in the library when they reach at least a working draft status. |
There is a spec, but not WD yet. |
Hi Is this the spec you were waiting for? https://wicg.github.io/web-share/ https://github.com/WICG/web-share/blob/master/docs/explainer.md Thanks in advance, |
Hi @OliverJAsh , I need to use WebShareApi in my Ionic/Angular app. Can you please explain your workaround i.e. "I am currently shimming the type locally". Any pointers on how to "shim a type locally"? |
18 months later the linked repo appears to have no activity and it's still not in Desktop Chrome at time of writing. Closing. |
Spec Level 1 (sharing text / links) is now implemented in Safari (Desktop & iOS) as well as on Android Chrome (source) Level 2 (sharing files / images) is being discussed and implementation is ongoing in Chrome. Would it be possible to get typings for Level 1? |
For anyone looking for a temporary solution, you can add this to your type ShareData = {
title? : string;
text? : string;
url? : string;
};
interface Navigator
{
share? : (data? : ShareData) => Promise<void>;
} |
For level 2 support, i recommend this one. files property should be FileList, but Filelist is readonly and can't be created dynamicaly. That's why I choose File[] instead. Also, important notes from developers.google.com:
type ShareData = {
title? : string;
text? : string;
url? : string;
files?: File[];
};
interface Navigator
{
share? : (data? : ShareData) => Promise<void>;
canShare?: (data?: ShareData) => boolean;
} |
Could you expand this into a tiny demo, and maybe post it to your git hub. I'm doing a Ionic/Angular/Capacitor PWA with and this my achilles heel. I've put a button in the index.html then click it from some typescript document.getElementByID, but that's really Jerry rigged. |
How about this instead of facilitate that requirement? type ShareData = {
title? : string;
text? : string;
url? : string;
files?: ReadonlyArray<File>;
};
interface Navigator
{
share? : (data? : ShareData) => Promise<void>;
canShare?: (data?: ShareData) => boolean;
} |
I'm in ionic 4/Angular 8/ Capacitor as a PWA: global.d.ts: // Added code - begin interface Navigator then how should i reference this? I tried adding it doesn't recognize the share method. That's why I was wondering if someone could make a small demo of it. My goal is to have the pwa popup the local instagram app popup with a post ready to process for the users when they click a button in my app. Any help would be appreciated. |
why this issue has been closed? |
I guess because the availability is way too limited for now. |
Port |
need to reopen this, 90% of browsers on mobile supports navigator.share |
Agree, it's up to the programmer to detect if the browser supports this feature or not. I don't see reason, why this should not be included in the library. |
I lean on to the side of yes for the level 1 support for this API. I have used this API myself in two separate projects, and re-implemented it in a React Native app - it's probably never going be broken and it's not really a valuable for desktops in the same way - so it's unlikely to make it to firefox. |
In that case I'll open a PR for this.
It's implemented in Firefox, just waiting for Microsoft to release the relevant API in stable builds. |
Ha, nice work - that PR is a good read too. 👍 |
The
window.navigator
Navigator
interface has a new propertyshare
https://developers.google.com/web/updates/2016/09/navigator-share.Would it be possible to add this to the DOM lib typings?
I am currently shimming the type locally:
The text was updated successfully, but these errors were encountered: