Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

319
Visualizações
Share a vcard (.vcf file) using the web share API

I'm trying to add a contact to a phone, by sharing a vcard (.vcf file) using the web share API, but its not working on android. It works just on my iPhone. Any idea about why its not working on android?

<html>
<title>
    Web Share API
</title>

<body>
    <div>
        <div>
            <button onclick="shareVcard" id="shareFilesButton">Share Files</button>
        </div>
    </div>
</body>
<script>
    document.getElementById('shareFilesButton').addEventListener("click", () => shareVcard())

function shareVcard() {
fetch("sample.vcf")
.then(function(response) {
    return response.text()
  })
.then(function(text) {

    var file = new File([text], "sample.vcf", {type: 'text/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 = "vcard";

    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.");
    }
 
});
    }
</script>

</html>

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda