- Support to open contact sheet and select a user and get their emails back.
Library | React Native |
---|---|
4 | 47+ |
3 | 40-46 |
2 | <=39 |
npm install doctadre/react-native-contact-picker
- In XCode, in the project navigator, right click
your project
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-contact-picker
and addContactPicker.m
- In XCode, open the Info.plist file and add a
Privacy - Contacts Usage Description
key/value - Run your project (
Cmd+R
)
if you do not have rnpm: npm install rnpm -g
rnpm link react-native-contact-picker
In AndroidManifest.xml
<!--add contact picker permissions-->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
Require the module var ContactPicker = require('NativeModules').ContactPicker;
'use strict';
var React = require('react-native');
var ContactPicker = require('NativeModules').ContactPicker;
then invoke:
onButtonPress() {
ContactPicker.pickContact().then((emails) => {
if (emails && emails.length) {
// list of contacts emails as strings
} else {
// either user hit cancel or the person they picked has no emails
}
});
}
MIT