# Web share api and vcard

**URL:** <https://discourse.mozilla.org/t/web-share-api-and-vcard/95913>\
**Category:** Learn\
**Created:** [April 13, 2022, 5:29pm UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913 "2022-04-13T17:29:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdelgadolima0586](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rdelgadolima0586/32/56333_2.png) [@rdelgadolima0586](https://discourse.mozilla.org/u/rdelgadolima0586)\
**Post date:** [April 13, 2022, 5:29pm UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/1 "2022-04-13T17:29:36Z")

</div>

Hi! I’d like to know if I can add a vcard (.vcf file) to a android phone by using the web share api?

---

<div class="post-metadata">

**Author:** ![schalkneethling](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/schalkneethling/32/22691_2.png) [@schalkneethling](https://discourse.mozilla.org/u/schalkneethling)\
**Post date:** [April 13, 2022, 6:26pm UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/2 "2022-04-13T18:26:26Z")

</div>

Have you tried calling `[canShare](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/canShare)` to see what it returns?

---

<div class="post-metadata">

**Author:** ![rdelgadolima0586](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rdelgadolima0586/32/56333_2.png) [@rdelgadolima0586](https://discourse.mozilla.org/u/rdelgadolima0586)\
**Post date:** [April 14, 2022, 10:54am UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/3 "2022-04-14T10:54:57Z")

</div>

Yes I did. My example works on ios, but not on android.

Here is my code.

export function shareVCard() {  
fetch(“sample.vcf”)  
.then(function(response) {  
return response.text()  
})  
.then(function(text) {

```
    var file = new File([text], "sample.vcf", {type: 'text/vcard'}); //text/x-vcard
    var filesArray = [file];
    var shareData = { files: filesArray };

    if (navigator.canShare && navigator.canShare(shareData)) {

    // Adding title afterwards as navigator.canShare just
    // takes files as input
    shareData.title = "Sample";

    navigator.share(shareData)
    .then(() => console.log('Share was successful.'))
    .catch((error) => console.log('Sharing failed', error));

    } else {
    console.log("Your system doesn't support sharing files.");
    }
});

```

}

---

<div class="post-metadata">

**Author:** ![schalkneethling](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/schalkneethling/32/22691_2.png) [@schalkneethling](https://discourse.mozilla.org/u/schalkneethling)\
**Post date:** [April 14, 2022, 5:20pm UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/4 "2022-04-14T17:20:30Z")

</div>

> [@rdelgadolima0586](#):
>
> `console.log("Your system doesn't support sharing files.");`

Do you get the above when running on Android? I have to admit I am not very familiar with the Web Share API. If you see the above on Android then I guess it is not yet supported. I looks like Chrome on Android does support it but not the Android web view: [Web Share API - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API#browser_compatibility)

Is your web application perhaps run inside a web view?

---

<div class="post-metadata">

**Author:** ![rdelgadolima0586](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rdelgadolima0586/32/56333_2.png) [@rdelgadolima0586](https://discourse.mozilla.org/u/rdelgadolima0586)\
**Post date:** [April 14, 2022, 5:52pm UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/5 "2022-04-14T17:52:17Z")

</div>

I’m running it on the android chrome browser, it supports the web share api. When I share a .txt file or an image it works, but not when it comes to a .vcf file, the issue might be with the .vcf. When I share the .vcf file on ios chrome it works.

---

<div class="post-metadata">

**Author:** ![schalkneethling](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/schalkneethling/32/22691_2.png) [@schalkneethling](https://discourse.mozilla.org/u/schalkneethling)\
**Post date:** [April 15, 2022, 10:32am UTC](https://discourse.mozilla.org/t/web-share-api-and-vcard/95913/6 "2022-04-15T10:32:08Z")

</div>

Ha! That is interesting. I wonder, perhaps it is worth raising an issue on the BCD repo? [https://github.com/mdn/browser-compat-data/issues/new/choose](https://github.com/mdn/browser-compat-data/issues/new/choose)
