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