Repository: cordova-plugin-contacts Updated Branches: refs/heads/master e5768f232 -> 0623f67ac
CB-10784: CDVContactsPicker finish animating before callback This closes #107 Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/0623f67a Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/0623f67a Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/0623f67a Branch: refs/heads/master Commit: 0623f67ac03c7591c2d28168ffbe52c60f17d89b Parents: e5768f2 Author: Cory Thompson <[email protected]> Authored: Fri Mar 4 10:52:28 2016 +1100 Committer: Julio César <[email protected]> Committed: Mon Mar 13 23:48:46 2017 +0100 ---------------------------------------------------------------------- src/ios/CDVContacts.m | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/0623f67a/src/ios/CDVContacts.m ---------------------------------------------------------------------- diff --git a/src/ios/CDVContacts.m b/src/ios/CDVContacts.m index 14fce2c..6b23033 100644 --- a/src/ios/CDVContacts.m +++ b/src/ios/CDVContacts.m @@ -79,10 +79,10 @@ recordId = ABRecordGetRecordID(person); } - [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil]; - - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:recordId]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES completion:^{ + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:recordId]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + }]; } - (bool)existsValue:(NSDictionary*)dict val:(NSString*)expectedValue forKey:(NSString*)key @@ -253,18 +253,17 @@ CFRelease(addrBook); } - CDVPluginResult* result = nil; NSNumber* recordId = picker.pickedContactDictionary[kW3ContactId]; - if ([recordId isEqualToNumber:[NSNumber numberWithInt:kABRecordInvalidID]]) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:OPERATION_CANCELLED_ERROR] ; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary]; - } - - [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId]; - - [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil]; + [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:^{ + CDVPluginResult* result = nil; + if ([recordId isEqualToNumber:[NSNumber numberWithInt:kABRecordInvalidID]]) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:OPERATION_CANCELLED_ERROR] ; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary]; + } + [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId]; + }]; } // Called after a person has been selected by the user. @@ -289,10 +288,10 @@ NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields]; picker.pickedContactDictionary = [pickedContact toDictionary:returnFields]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary]; - [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId]; - - [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil]; + [[picker presentingViewController] dismissViewControllerAnimated:YES completion:^{ + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary]; + [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId]; + }]; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
