diff options
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; +}; |