aboutsummaryrefslogtreecommitdiff
path: root/src/utils/common.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/common.ts')
-rw-r--r--src/utils/common.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts
index c1049c42..5f0e26ba 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,21 @@ export const shuffle = (array: any[]) => {
return array;
};
+
+export const extractContacts = async () => {
+ let retrievedContacts: Array<ContactType> = [];
+ await getAll().then((contacts) => {
+ contacts.map((contact) => {
+ let obj: ContactType = {
+ first_name: contact.givenName,
+ last_name: contact.familyName,
+ };
+ contact.phoneNumbers.map(async (phoneNumber) => {
+ obj.phone_number = phoneNumber.number;
+ retrievedContacts.push(obj);
+ console.log('contact: ', obj);
+ });
+ });
+ });
+ return retrievedContacts;
+};