merging. molecule updates.
This commit is contained in:
parent
4400682469
commit
1d968bd2c1
@ -272,40 +272,39 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
NSString *MDN = [actionInformation string:KeyCallNumber];
|
||||
NSString *phoneNumber = [actionInformation string:@"phoneNumber"];
|
||||
|
||||
if (MDN) {
|
||||
CNMutableContact *contact = [[CNMutableContact alloc] init];
|
||||
NSString *approach = [actionInformation stringForKey:@"approach"];
|
||||
|
||||
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]];
|
||||
contact.phoneNumbers = @[phone];
|
||||
|
||||
if ([approach isEqualToString:KeyAdd]) {
|
||||
[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];
|
||||
}];
|
||||
} else if ([approach isEqualToString:KeyCreate]) {
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
contact.givenName = [actionInformation string:@"firstName"];
|
||||
contact.familyName = [actionInformation string:@"lastName"];
|
||||
|
||||
CNContactStore *store = [[CNContactStore alloc] init];
|
||||
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact];
|
||||
controller.contactStore = store;
|
||||
controller.delegate = weakSelf;
|
||||
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: controller];
|
||||
navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
|
||||
|
||||
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
||||
}];
|
||||
}
|
||||
if (!phoneNumber) { return; }
|
||||
CNMutableContact *contact = [[CNMutableContact alloc] init];
|
||||
NSString *approach = [actionInformation stringForKey:@"approach"];
|
||||
|
||||
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:phoneNumber]];
|
||||
contact.phoneNumbers = @[phone];
|
||||
|
||||
if ([approach isEqualToString:KeyAdd]) {
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init];
|
||||
// Setting to accessibilityValue as a workaround to pass data via the delegate function.
|
||||
[controller setAccessibilityValue:phoneNumber];
|
||||
controller.delegate = weakSelf;
|
||||
|
||||
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
||||
}];
|
||||
} else if ([approach isEqualToString:KeyCreate]) {
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
contact.givenName = [actionInformation string:@"firstName"];
|
||||
contact.familyName = [actionInformation string:@"lastName"];
|
||||
|
||||
CNContactStore *store = [[CNContactStore alloc] init];
|
||||
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact];
|
||||
controller.contactStore = store;
|
||||
controller.delegate = weakSelf;
|
||||
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
|
||||
navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
|
||||
|
||||
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,26 +404,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 *MDN = picker.accessibilityValue;
|
||||
NSString *phoneNumber = picker.accessibilityValue;
|
||||
|
||||
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];
|
||||
}];
|
||||
}
|
||||
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];
|
||||
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
|
||||
|
||||
@ -17,7 +17,7 @@ import ContactsUI
|
||||
public static var identifier: String = "contact"
|
||||
public var actionType: String = ActionCallModel.identifier
|
||||
// TODO: decode into phone number once action handler is re-written
|
||||
public var callNumber: String
|
||||
public var phoneNumber: String
|
||||
public var firstName: String?
|
||||
public var lastName: String?
|
||||
public var approach: String = KeyCreate
|
||||
@ -28,8 +28,8 @@ import ContactsUI
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
self.callNumber = callNumber
|
||||
public init(phoneNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
self.phoneNumber = phoneNumber
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.approach = approach
|
||||
|
||||
Loading…
Reference in New Issue
Block a user