npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-vcards

v2.5.0

Published

Create vCards to import contacts into Outlook, iOS, Mac OS, Android devices, and more.

Downloads

4,849

Readme

React Native vCards - vCards JS for use with React Native

Build Status

Updated for newer versions of react-native-fs. Now listed as a peerDependency.

Create vCards to import contacts into Outlook, iOS, Mac OS, and Android devices from your website or application.

Screenshot

Install

Note that this package requires react-native-fs for saving files. If you have installed rnpm, the easy way to install react-native-fs is the following:

npm install react-native-fs && rnpm link react-native-fs

Then to install this package, run the following:

npm install react-native-vcards@https://github.com/idxbroker/react-native-vcards.git --save

Usage

Below is a simple example of how to create a basic vCard and how to save it to a file, or view its contents from the console.

Basic vCard

import vCard from 'react-native-vcards';

//create a new vCard
contact = vCard();

//set properties
contact.firstName = 'Eric';
contact.middleName = 'J';
contact.lastName = 'Nesser';
contact.organization = 'ACME Corporation';
contact.photo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG');
contact.workPhone = '312-555-1212';
contact.birthday = new Date('01-01-1985');
contact.title = 'Software Developer';
contact.url = 'https://github.com/enesser';
contact.note = 'Notes on Eric';

//save to file
contact.saveToFile('./eric-nesser.vcf');

//get as formatted string
console.log(contact.getFormattedString());

Embedding Images

You can embed images in the photo or logo field instead of linking to them from a URL using base64 encoding.

//can be Windows or Linux/Unix path structures, and JPEG, PNG, GIF formats
contact.photo.embedFromFile('/path/to/file.png');
contact.logo.embedFromFile('/path/to/file.png');

Complete Example

The following shows a vCard with everything filled out.

import vCard from 'react-native-vcards';

//create a new vCard
contact = vCard();

//set basic properties shown before
contact.firstName = 'Eric';
contact.middleName = 'J';
contact.lastName = 'Nesser';
contact.organization = 'ACME Corporation';

//link to image
contact.photo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG');

//or embed image
contact.photo.attachFromUrl('/path/to/file.jpeg');

contact.workPhone = '312-555-1212';
contact.birthday = new Date('01-01-1985');
contact.title = 'Software Developer';
contact.url = 'https://github.com/enesser';
contact.workUrl = 'https://acme-corporation/enesser';
contact.note = 'Notes on Eric';

//set other vitals
contact.nickname = 'Scarface';
contact.namePrefix = 'Mr.';
contact.nameSuffix = 'JR';
contact.gender = 'M';
contact.anniversary = new Date('01-01-2004');
contact.role = 'Software Development';

//set other phone numbers
contact.homePhone = '312-555-1313';
contact.cellPhone = '312-555-1414';
contact.pagerPhone = '312-555-1515';

// set fax/ facsimile numbers
contact.homeFax = '312-555-1616';
contact.workFax = '312-555-1717';

// set email addresses
contact.email = '[email protected]';
contact.workEmail = '[email protected]';

//set logo of organization or personal logo (also supports embedding, see above)
contact.logo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG');

//set URL where the vCard can be found
contact.source = 'http://mywebpage/myvcard.vcf';

//set address information
contact.homeAddress.label = 'Home Address';
contact.homeAddress.street = '123 Main Street';
contact.homeAddress.city = 'Chicago';
contact.homeAddress.stateProvince = 'IL';
contact.homeAddress.postalCode = '12345';
contact.homeAddress.countryRegion = 'United States of America';

contact.workAddress.label = 'Work Address';
contact.workAddress.street = '123 Corporate Loop\nSuite 500';
contact.workAddress.city = 'Los Angeles';
contact.workAddress.stateProvince = 'CA';
contact.workAddress.postalCode = '54321';
contact.workAddress.countryRegion = 'United States of America';

//set social media URLs
contact.socialUrls['facebook'] = 'https://...';
contact.socialUrls['linkedIn'] = 'https://...';
contact.socialUrls['twitter'] = 'https://...';
contact.socialUrls['flickr'] = 'https://...';
contact.socialUrls['custom'] = 'https://...';

//you can also embed photos from files instead of attaching via URL
contact.photo.embedFromFile('photo.jpg');
contact.logo.embedFromFile('logo.jpg');

contact.version = '3.0'; //can also support 2.1 and 4.0, certain versions only support certain fields

//save to file
const documentPath = rnfs.DocumentDirectoryPath;
contact.saveToFile(`${documentPath}/eric-nesser.vcf`);

//get as formatted string
console.log(contact.getFormattedString());

Contributions

Contributions are always welcome!

Thanks to mplno, lop-cz, jkrenge.

License

Copyright (c) 2014-2015 Eric J Nesser MIT