Skip to content

Commit

Permalink
Document android permissions request
Browse files Browse the repository at this point in the history
closes #218
  • Loading branch information
morenoh149 authored Jan 18, 2019
1 parent f91716b commit 864dc88
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Ask questions on [stackoverflow](https://stackoverflow.com/questions/tagged/reac
import Contacts from 'react-native-contacts';

Contacts.getAll((err, contacts) => {
if (err) throw err;

if (err) {
throw err;
}
// contacts returned
console.log(contacts)
})
```

Expand All @@ -23,10 +23,32 @@ Contacts.getAll((err, contacts) => {
import Contacts from 'react-native-contacts';

Contacts.getContactsMatchingString("filter", (err, contacts) => {
if (err) throw err;

if (err) {
throw err;
}
// contacts matching "filter"
console.log(contacts)
})
```
### Android permissions
On android you must request permissions beforehand
```es
import { PermissionsAndroid } from 'react-native';
import Contacts from 'react-native-contacts';

PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'This app would like to view your contacts.'
}
).then(() => {
Contacts.getAll((err, contacts) => {
if (err === 'denied'){
// error
} else {
// contacts returned in Array
}
})
})
```
## Installation
Expand Down

0 comments on commit 864dc88

Please sign in to comment.