diff options
author | Ivan Chen <ivan@tagg.id> | 2021-03-18 19:48:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 19:48:53 -0400 |
commit | aa0ddb7c5a6612ff067f7dce1c6d5b083db44309 (patch) | |
tree | 89326275ce5ff4e48bc29952c60856258cd8b0ab /src/utils/common.ts | |
parent | 07a15098625786451270e30e61e2d6e78c02d4db (diff) | |
parent | 9a7e34bf992e0bfa3b9ce7d83643d97fad209e6e (diff) |
Merge pull request #303 from shravyaramesh/add-friends-thru-contacts
[TMA-622] Add friends from contacts
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; +}; |