# react-native-select-contact

> A react native company to select a contact from your phone's contact list

Latest version **1.6.3** (published 2021-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-select-contact
pnpm add react-native-select-contact
yarn add react-native-select-contact
bun add react-native-select-contact
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.3 |
| Published | 2021-06-04 |
| First published | 2018-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 178.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 116 |
| Author | Streem |
| Maintainers | sadkinson |
| Keywords | react, react-native, contacts, address book, people, select contact |

## Links

- npm: https://www.npmjs.com/package/react-native-select-contact
- Repository: https://github.com/streem/react-native-select-contact
- Issues: https://github.com/streem/react-native-select-contact/issues
- npm.io page: https://npm.io/package/react-native-select-contact

## Dependencies (1)

- [react-native-action-sheet](https://npm.io/package/react-native-action-sheet.md) ^2.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.6.3 (latest) — 2021-06-04
- 1.6.2 — 2021-06-02
- 1.6.1 — 2021-06-02
- 1.6.0 — 2021-06-02
- 1.5.0 — 2020-07-07
- 1.4.0 — 2020-07-07
- 1.3.2 — 2020-03-25
- 1.3.1 — 2020-03-20
- 1.3.0 — 2020-03-03
- 1.2.1 — 2019-07-20
- 1.2.0 — 2019-03-12
- 1.1.1 — 2018-08-09
- 1.1.0 — 2018-08-07
- 1.0.0 — 2018-06-06
- 0.0.13 — 2018-06-05
- … 12 more at https://npm.io/package/react-native-select-contact/versions

## README

# react-native-select-contact

Originally branched from [react-native-contacts-wrapper](https://github.com/LynxITDigital/react-native-contacts-wrapper)

This is a simple wrapper for the native iOS and Android Contact Picker UIs, with some optional help for selecting specific fields from the contact.

### Installation

```
yarn add react-native-select-contact
```

For React Native => 0.59 only:
```
react-native link react-native-select-contact
```

Make sure your manifest files includes permission to read contacts
```
<uses-permission android:name="android.permission.READ_CONTACTS" />
```

### API

#### Methods

```
selectContact(): Promise<Contact | null>;
selectContactPhone(): Promise<ContactPhoneSelection | null>;
selectContactEmail(): Promise<ContactEmailSelection | null>;
selectContactPostalAddress(): Promise<ContactPostalAddressSelection | null>;
```

These methods all open up a separate ViewController (on IOS) or Activity (on Android) to select a contact.  See Types below.

For `selectContactPhone`, `selectContactEmail`, or `selectContactPostalAddress`, if there are more than one phone or email, an `ActionSheetIOS` is
shown for IOS, and the first entry is returned for Android.

A return value `null` may be because the user cancelled the contact selection.  You shouldn't need to worry about doing
anything if the promise resolves to `null`.

#### Optional Android ActionSheet

You can enable ActionSheet functionality for Android by installing an optional dependency:

```
yarn add react-native-action-sheet
```

For React Native => 0.59 only:
```
react-native link react-native-action-sheet
```

This will provide an `ActionSheetAndroid` native module that this library will pick up on and use
when there are more than one phone number or email on a selected contact.

#### Types

```typescript
interface PhoneEntry {
    number: string,
    type: string
}

interface EmailEntry {
    address: string,
    type: string
}

interface AddressEntry {
    formattedAddress: string, // android only
    type: string, // android only
    street: string,
    city: string,
    state: string,
    postalCode: string,
    isoCountryCode: string
}

interface Contact {
    name: string,
    phones: PhoneEntry[],
    emails: EmailEntry[],
    postalAddresses: AddressEntry[]
}

interface ContactPhoneSelection {
    contact: Contact,
    selectedPhone: PhoneEntry
}

interface ContactEmailSelection {
    contact: Contact,
    selectedEmail: EmailEntry
}

interface ContactPostalAddressSelection {
    contact: Contact,
    selectedAddress: AddressEntry
}
```

### Example

```javascript

import { selectContactPhone } from 'react-native-select-contact';

function getPhoneNumber() {
    return selectContactPhone()
        .then(selection => {
            if (!selection) {
                return null;
            }
            
            let { contact, selectedPhone } = selection;
            console.log(`Selected ${selectedPhone.type} phone number ${selectedPhone.number} from ${contact.name}`);
            return selectedPhone.number;
        });  
}


```

---
_Source: https://npm.io/package/react-native-select-contact · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
