enesser / vCards-js

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

Social links aren't showing after vcard downloaded #56

Open 744322 opened 3 years ago

744322 commented 3 years ago

Actually I am facing the problem regarding the social links after downloading the vcard file just because it's not showing the social links in my vcard after download. Here is the code: var vCardsJS = require('vcards-js'); //create a new vCard var vCard = vCardsJS();

//set properties vCard.firstName = name; vCard.organization = companyName; vCard.workPhone = phone; vCard.url = website; vCard.workEmail = email; vCard.socialUrls['facebook'] = facebook; vCard.socialUrls['instagram'] = instagram; vCard.socialUrls['twitter'] = twitter; vCard.socialUrls['youtube'] = youtube; vCard.socialUrls['snapchat'] = snapchat; vCard.socialUrls['tiktok'] = tiktok; vCard.socialUrls['whatsapp'] = whatsapp; vCard.socialUrls['pinterest'] = pinterest; let card = await vCard.getFormattedString(); Links are coming from my site front-end.

yasmanets commented 3 years ago

Is it an iOS or Android device? Labels don't work for both. I suggest you look at these PR https://github.com/enesser/vCards-js/pull/51 https://github.com/enesser/vCards-js/pull/52

mgecawicz commented 3 years ago

I did find a solution, but it is a bit of a workaround. I did some research on VCF formatting conventions and created the following edit to the vCardFormatter.js file which produces the desired effect:

if (vCard.socialUrls) { for (var key in vCard.socialUrls) { index++; if (vCard.socialUrls.hasOwnProperty(key) && vCard.socialUrls[key]) { formattedVCardString += 'item' + index + '.URL:' + vCard.socialUrls[key] + nl(); formattedVCardString += 'item' + index + '.X-ABLabel:' + key + nl(); // formattedVCardString += 'X-SOCIALPROFILE' + encodingPrefix + ';type=' + key + ':' + e(vCard.socialUrls[key]) + nl(); } } }