for reference.

This commit is contained in:
Kevin G Christiano 2021-04-07 15:37:40 -04:00
parent c3601741c8
commit dc90af50b2

View File

@ -257,48 +257,50 @@ NSString * const KeyActionTypeOpen = @"openPage";
}
}
// TODO: Need to ask user for permission to accss their contacts
// Privacy - Contacts Usage Description
// Access is needed to save your friends information to your Contacts list.
- (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
__weak typeof(self) weakSelf = self;
NSString *MDN = [actionInformation string:KeyCallNumber];
if (MDN) {
CNMutableContact *contact = [[CNMutableContact alloc] init];
NSString *approach = [actionInformation stringForKey:@"approach"];
// CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
//
// if (status == CNAuthorizationStatusAuthorized) {
__weak typeof(self) weakSelf = self;
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]];
contact.phoneNumbers = @[phone];
NSString *MDN = [actionInformation string:KeyCallNumber];
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 (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];
}];
}
}
}
// }
}
- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {