contact behavior

This commit is contained in:
Kevin G Christiano 2021-04-07 14:15:12 -04:00
parent f5613644a0
commit 4686dc8256

View File

@ -274,9 +274,10 @@ NSString * const KeyActionTypeOpen = @"openPage";
contact.phoneNumbers = @[phone];
if ([approach isEqualToString:KeyAdd]) {
// Nothing for now.
[MVMCoreDispatchUtility performBlockOnMainThread:^{
CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init];
// Setting to accessibilityValue as a workaround to pass data via the delegate function.
[controller setAccessibilityValue:MDN];
controller.delegate = weakSelf;
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
@ -395,22 +396,27 @@ NSString * const KeyActionTypeOpen = @"openPage";
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
CNContactStore *store = [[CNContactStore alloc] init];
CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy];
CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:@"1234567890"];
CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number];
NSMutableArray<CNLabeledValue *> *phoneNumbers = [NSMutableArray new];
[phoneNumbers addObject:labelValue];
[phoneNumbers addObjectsFromArray:existingContact.phoneNumbers];
existingContact.phoneNumbers = phoneNumbers;
// This is a means to pass the data to this delegate function.
NSString *MDN = picker.accessibilityValue;
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
controller.contactStore = store;
controller.delegate = self;
[MVMCoreDispatchUtility performBlockOnMainThread:^{
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
}];
if (MDN) {
CNContactStore *store = [[CNContactStore alloc] init];
CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy];
CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:MDN];
CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number];
NSMutableArray<CNLabeledValue *> *phoneNumbers = [NSMutableArray new];
[phoneNumbers addObject:labelValue];
[phoneNumbers addObjectsFromArray:existingContact.phoneNumbers];
existingContact.phoneNumbers = phoneNumbers;
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
controller.contactStore = store;
controller.delegate = self;
[MVMCoreDispatchUtility performBlockOnMainThread:^{
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
}];
}
}
#pragma mark - Open URL