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 // 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 { - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
__weak typeof(self) weakSelf = self; // CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
//
// if (status == CNAuthorizationStatusAuthorized) {
__weak typeof(self) weakSelf = self;
NSString *MDN = [actionInformation string:KeyCallNumber]; NSString *MDN = [actionInformation string:KeyCallNumber];
if (MDN) { if (MDN) {
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:MDN]];
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:MDN];
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];
}]; }];
}
} }
} // }
} }
- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {