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;
NSString *MDN = [actionInformation string:KeyCallNumber]; // CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
//
if (MDN) { // if (status == CNAuthorizationStatusAuthorized) {
CNMutableContact *contact = [[CNMutableContact alloc] init]; __weak typeof(self) weakSelf = self;
NSString *approach = [actionInformation stringForKey:@"approach"];
CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; NSString *MDN = [actionInformation string:KeyCallNumber];
contact.phoneNumbers = @[phone];
if ([approach isEqualToString:KeyAdd]) { if (MDN) {
[MVMCoreDispatchUtility performBlockOnMainThread:^{ CNMutableContact *contact = [[CNMutableContact alloc] init];
CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init]; NSString *approach = [actionInformation stringForKey:@"approach"];
// Setting to accessibilityValue as a workaround to pass data via the delegate function.
[controller setAccessibilityValue:MDN]; CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]];
controller.delegate = weakSelf; contact.phoneNumbers = @[phone];
[[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; if ([approach isEqualToString:KeyAdd]) {
}]; [MVMCoreDispatchUtility performBlockOnMainThread:^{
} else if ([approach isEqualToString:KeyCreate]) { CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init];
[MVMCoreDispatchUtility performBlockOnMainThread:^{ // Setting to accessibilityValue as a workaround to pass data via the delegate function.
contact.givenName = [actionInformation string:@"firstName"]; [controller setAccessibilityValue:MDN];
contact.familyName = [actionInformation string:@"lastName"]; controller.delegate = weakSelf;
CNContactStore *store = [[CNContactStore alloc] init]; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES];
CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:contact]; }];
controller.contactStore = store; } else if ([approach isEqualToString:KeyCreate]) {
controller.delegate = weakSelf; [MVMCoreDispatchUtility performBlockOnMainThread:^{
contact.givenName = [actionInformation string:@"firstName"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: controller]; contact.familyName = [actionInformation string:@"lastName"];
navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
CNContactStore *store = [[CNContactStore alloc] init];
[[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; 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 { - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {