- SDK Version: 38.0.8
- Platforms(Android/iOS/web/all): Android
Hi there, I’ve used Expo Contacts and getContactsAsync successfully before, but now it’s not returning anything. The only things I’m doing differently this time are using it inside of a Redux thunk and using it with the newly released Android 11. Here’s my code:
import * as Contacts from 'expo-contacts';
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import sortContacts from '../components/SortContacts';
export const fetchContacts = createAsyncThunk('contacts/fetchContacts', async () => {
const { status } = await Contacts.requestPermissionsAsync();
if (status === 'granted') {
const { contacts }: any = await Contacts.getContactsAsync().catch((error) => {console.error(error)});
return(sortContacts(contacts));
}
});
Using console.log
, I’ve determined that the status is correctly returned as 'granted'
, but 'contacts'
is always void.
I’ve looked through all relevant forum topics but haven’t found a solution. Any help would be much appreciated!
Edit: I’ve tried running it on older versions of Android on an emulator and still get the same result. Evaluating 'contacts'
results in 'undefined is not an object'
.