diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:25:29 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:25:29 -0400 |
| commit | cc1b5a0be911dc05386a5114e966b7ee4eb21441 (patch) | |
| tree | 90fad5a8ed92206b3026e8fd033b4d35360884f7 /src/utils/common.ts | |
| parent | 96477697afe4dd92ce68f0f778decbca30d83e77 (diff) | |
| parent | 33c107f7382955f6993d8415f08262f51060d178 (diff) | |
Merge branch 'master' into tma698-api-profile
# Conflicts:
# src/components/search/SearchBar.tsx
Diffstat (limited to 'src/utils/common.ts')
| -rw-r--r-- | src/utils/common.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts index c1049c42..0a76ec08 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -1,8 +1,9 @@ -import {NotificationType} from './../types/types'; +import {ContactType, NotificationType} from './../types/types'; import moment from 'moment'; import {Linking} from 'react-native'; import {BROWSABLE_SOCIAL_URLS, TOGGLE_BUTTON_TYPE} from '../constants'; import AsyncStorage from '@react-native-community/async-storage'; +import {getAll} from 'react-native-contacts'; export const getToggleButtonText: ( buttonType: string, @@ -115,3 +116,19 @@ export const shuffle = (array: any[]) => { return array; }; + +export const extractContacts = async () => { + let retrievedContacts: Array<ContactType> = []; + await getAll().then((contacts) => { + contacts.map((contact) => { + contact.phoneNumbers.map((phoneNumber) => { + retrievedContacts.push({ + first_name: contact.givenName, + last_name: contact.familyName, + phone_number: phoneNumber.number, + }); + }); + }); + }); + return retrievedContacts; +}; |
