enesser / vCards-js

Create vCards to import contacts into Outlook, iOS, Mac OS, and Android devices from your website or application.
MIT License
430 stars 158 forks source link

( iOS issue ) vcf not showing up on its own....nee to click on download folder to verify #77

Open oldots opened 1 year ago

oldots commented 1 year ago

vcards-js is not working on ios. Tried everything from our end. It gets downloaded on safari but user needs to go to download folder to check if it downloaded and then it does not show option to save. it just show contact card and no option to save on iphone device. on Chrome, vcf card does not get download at all. It is working absolutely fine on android devices though. We are using it on our webapp to download user contact card.

cesswhite commented 1 year ago

Hi! with this code I was able to show a preview of the VCard directly, without going through the download folder on iPhone.

 let fileURL = `data:text/vcard;charset=utf-8, ${encodeURIComponent(
   vCard.getFormattedString(),
  )}`;
  let fileLink = document.createElement('a');
  fileLink.href = fileURL;
  fileLink.setAttribute('download', `./${username.value}.vcf`);
  document.body.appendChild(fileLink);
  fileLink.click();