diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 7fc063a..15fab4e 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -33,8 +33,10 @@ NSString * const KeyActionType = @"actionType"; NSString * const KeyActionTypeLinkAway = @"openURL"; NSString * const KeyActionTypeOpen = @"openPage"; -@implementation MVMCoreActionHandler +@interface MVMCoreActionHandler() +@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 *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]; }]; }