react-native-select-contact: Cannot selectContactPhone on iOS
When using “selectContactPhone” nothing happens.
Code:
selectContactPhone()
.then(selection => {
if (!selection) {
return null;
}
let { contact, selectedPhone } = selection;
console.log(`Selected ${selectedPhone.type} phone number ${selectedPhone.number} from ${contact.name}`);
return selectedPhone.number;
});
Logs:
[reports] Main Thread Checker: UI API called on a background thread: -[UIWindow rootViewController] PID: 450, TID: 136063, Thread name: (none), Queue name: com.facebook.react.SelectContactQueue, QoS: 0 [Assert] Cannot be called with asCopy = NO on non-main thread. [Assert] Cannot be called with asCopy = NO on non-main thread. Warning: Attempt to present <CNContactPickerViewController: 0x1038f5730> on <RNNStackController: 0x104005000> whose view is not in the window hierarchy!
Using RN version 0.60.4 and react-native-navigation 4.0.8
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 17 (2 by maintainers)
So after a lot of searching, I found the solution. I was using a modal and closing that modal at the time of opening the contact list, that was the mistake. What IOS does is, links the native UI screen with the last app screen and in my case, it was that modal screen. As that modal screen is no more present, IOS wasn’t able to show that native UI screen. The solution was pretty simple, I close the modal after the user interaction.