moved protocol.

This commit is contained in:
Kevin G Christiano 2021-04-12 13:44:27 -04:00
parent 4ba0e3adfb
commit e54a414814

View File

@ -33,8 +33,10 @@ NSString * const KeyActionType = @"actionType";
NSString * const KeyActionTypeLinkAway = @"openURL";
NSString * const KeyActionTypeOpen = @"openPage";
@implementation MVMCoreActionHandler
@interface MVMCoreActionHandler() <CNContactViewControllerDelegate, CNContactPickerDelegate>
@end
@implementation MVMCoreActionHandler
+ (nullable instancetype)sharedActionHandler {
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].actionHandler classToVerify:self];
}
@ -285,7 +287,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
[MVMCoreDispatchUtility performBlockOnMainThread:^{
CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init];
// Setting to accessibilityValue as a workaround to pass data via the delegate function.
[controller setAccessibilityValue:phoneNumber];
[controller.view setAccessibilityIdentifier:phoneNumber];
controller.delegate = weakSelf;
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
@ -404,23 +406,25 @@ NSString * const KeyActionTypeOpen = @"openPage";
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
// This is a means to pass the data to this delegate function.
NSString *phoneNumber = picker.accessibilityValue;
NSString *phoneNumber = picker.view.accessibilityIdentifier;
if (!phoneNumber) { return; }
CNContactStore *store = [[CNContactStore alloc] init];
CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy];
CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:phoneNumber];
CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number];
CNMutableContact *existingContact = [(CNMutableContact *)contact mutableCopy];
CNPhoneNumber *number = [[CNPhoneNumber alloc] initWithStringValue:phoneNumber];
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;
__weak typeof(self) weakSelf = self;
[MVMCoreDispatchUtility performBlockOnMainThread:^{
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
controller.contactStore = store;
controller.delegate = weakSelf;
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
}];
}