contact behavior
This commit is contained in:
parent
f5613644a0
commit
4686dc8256
@ -274,9 +274,10 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
|||||||
contact.phoneNumbers = @[phone];
|
contact.phoneNumbers = @[phone];
|
||||||
|
|
||||||
if ([approach isEqualToString:KeyAdd]) {
|
if ([approach isEqualToString:KeyAdd]) {
|
||||||
// Nothing for now.
|
|
||||||
[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.
|
||||||
|
[controller setAccessibilityValue:MDN];
|
||||||
controller.delegate = weakSelf;
|
controller.delegate = weakSelf;
|
||||||
|
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
||||||
@ -395,22 +396,27 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
|||||||
|
|
||||||
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
|
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
|
||||||
|
|
||||||
CNContactStore *store = [[CNContactStore alloc] init];
|
// This is a means to pass the data to this delegate function.
|
||||||
CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy];
|
NSString *MDN = picker.accessibilityValue;
|
||||||
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;
|
|
||||||
|
|
||||||
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
|
if (MDN) {
|
||||||
controller.contactStore = store;
|
CNContactStore *store = [[CNContactStore alloc] init];
|
||||||
controller.delegate = self;
|
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;
|
||||||
|
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
controller.contactStore = store;
|
||||||
}];
|
controller.delegate = self;
|
||||||
|
|
||||||
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
|
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
||||||
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Open URL
|
#pragma mark - Open URL
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user