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;
|
__weak typeof(self) weakSelf = self;
|
||||||
|
|
||||||
NSString *MDN = [actionInformation string:KeyCallNumber];
|
NSString *phoneNumber = [actionInformation string:@"phoneNumber"];
|
||||||
|
|
||||||
if (MDN) {
|
if (!phoneNumber) { return; }
|
||||||
CNMutableContact *contact = [[CNMutableContact alloc] init];
|
CNMutableContact *contact = [[CNMutableContact alloc] init];
|
||||||
NSString *approach = [actionInformation stringForKey:@"approach"];
|
NSString *approach = [actionInformation stringForKey:@"approach"];
|
||||||
|
|
||||||
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]];
|
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:phoneNumber]];
|
||||||
contact.phoneNumbers = @[phone];
|
contact.phoneNumbers = @[phone];
|
||||||
|
|
||||||
if ([approach isEqualToString:KeyAdd]) {
|
if ([approach isEqualToString:KeyAdd]) {
|
||||||
[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:MDN];
|
[controller setAccessibilityValue:phoneNumber];
|
||||||
controller.delegate = weakSelf;
|
controller.delegate = weakSelf;
|
||||||
|
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
|
||||||
}];
|
}];
|
||||||
} else if ([approach isEqualToString:KeyCreate]) {
|
} else if ([approach isEqualToString:KeyCreate]) {
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
contact.givenName = [actionInformation string:@"firstName"];
|
contact.givenName = [actionInformation string:@"firstName"];
|
||||||
contact.familyName = [actionInformation string:@"lastName"];
|
contact.familyName = [actionInformation string:@"lastName"];
|
||||||
|
|
||||||
CNContactStore *store = [[CNContactStore alloc] init];
|
CNContactStore *store = [[CNContactStore alloc] init];
|
||||||
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact];
|
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact];
|
||||||
controller.contactStore = store;
|
controller.contactStore = store;
|
||||||
controller.delegate = weakSelf;
|
controller.delegate = weakSelf;
|
||||||
|
|
||||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: controller];
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
|
||||||
navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
|
navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
|
||||||
|
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
||||||
}];
|
}];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,26 +404,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 *MDN = picker.accessibilityValue;
|
NSString *phoneNumber = picker.accessibilityValue;
|
||||||
|
|
||||||
if (MDN) {
|
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:MDN];
|
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];
|
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact];
|
||||||
controller.contactStore = store;
|
controller.contactStore = store;
|
||||||
controller.delegate = self;
|
controller.delegate = self;
|
||||||
|
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES];
|
||||||
}];
|
}];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Open URL
|
#pragma mark - Open URL
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import ContactsUI
|
|||||||
public static var identifier: String = "contact"
|
public static var identifier: String = "contact"
|
||||||
public var actionType: String = ActionCallModel.identifier
|
public var actionType: String = ActionCallModel.identifier
|
||||||
// TODO: decode into phone number once action handler is re-written
|
// 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 firstName: String?
|
||||||
public var lastName: String?
|
public var lastName: String?
|
||||||
public var approach: String = KeyCreate
|
public var approach: String = KeyCreate
|
||||||
@ -28,8 +28,8 @@ import ContactsUI
|
|||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
public init(phoneNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||||
self.callNumber = callNumber
|
self.phoneNumber = phoneNumber
|
||||||
self.firstName = firstName
|
self.firstName = firstName
|
||||||
self.lastName = lastName
|
self.lastName = lastName
|
||||||
self.approach = approach
|
self.approach = approach
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user