-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to determine when form is closed after calling Contacts.presentFormAsync on iOS #3696
Comments
i'm not sure if i'd consider this a bug - |
Well I would say this : the presentFormAsync is requested to be shown when there is a need from the app to update a contact, it means that the app will make a use of the updated contact. So there is a big chance the app is counting on the updated contact to keep doing what it was doing. The user would also expect the contact to be updated in the app once he finished updating it in his phonebook. |
it does sound like a reasonable expectation to be able to receive a signal somehow that the editing has completed. i looked into it and was hopeful that the promise would resolve from a workaround for this at the moment is to poll for changes to the contact after you open the form - certainly not ideal as you'd probably need to do a deep comparison on all fields. ideally, i think, we would want |
alright I'll have a look, but it would be my first PR ever on an open source project... I'll give it try |
well I feel a bit lost, I don't even know where to start... I checked the file export async function presentFormAsync(
contactId?: string | null,
contact?: Contact | null,
formOptions: FormOptions = {}
): Promise<any> {
if (!ExpoContacts.presentFormAsync) {
throw new UnavailabilityError('Contacts', 'presentFormAsync');
}
if (Platform.OS === 'ios') {
let adjustedOptions = formOptions;
if (contactId) {
if (contact) {
contact = undefined;
console.log(
'Expo.Contacts.presentFormAsync: You should define either a `contact` or a `contactId` but not both.'
);
}
if (adjustedOptions.isNew !== undefined) {
console.log(
'Expo.Contacts.presentFormAsync: formOptions.isNew is not supported with `contactId`'
);
}
}
return await ExpoContacts.presentFormAsync(contactId, contact, adjustedOptions);
} else {
return await ExpoContacts.presentFormAsync(contactId, contact, formOptions);
}
} Problem is : to resolve the promise when the modal is closed, I need to know how to know when a modal is closed, isn't it ? So, basically.... I really want to help and do the job, but I am really lost ! |
hey @arnaudambro - I think that this will need to be done on the native side. the first place to look would be here: expo/packages/expo-contacts/ios/EXContacts/EXContacts.m Lines 173 to 247 in 9df19ff
|
+1 I also believe it makes sense to resolve promise after the module is closed or have some callback property. Especially when creating a new contact there is no way in telling what the contact ID is after the contact was created. |
That's why I had to go for react-native-contacts. |
we have a lot to work on here, it is an open source project and you're welcome to open a pr. given that you have the implementation for what you want already in react-native-contacts it shouldn't be too tough :) |
That's actually really something I want to do, because expo has been a great tool to me. I'll do as soon as I can |
That would be amazing - I would offer it to try it too but I'm only a student and started using react native a month ago... |
problem solved in the next SDK |
Environment
Expo CLI 2.11.7 environment info:
System:
OS: macOS 10.14.3
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.1 - /usr/local/bin/node
Yarn: 1.13.0 - ~/.yarn/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.2
react: ^16.5.0 => 16.7.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
npmGlobalPackages:
expo-cli: 2.11.7
target: iOS on simulator
Steps to Reproduce
Contacts. presentFormAsync(id)
Expected Behavior
on Android, it is triggering the update of the AppState, then if I update my contact list based on the phonebook, I got my contact list updated every time I change a contact thanks to
presentFormAsync
. but not on iOSThe text was updated successfully, but these errors were encountered: