From 3a4e317ccf82c9791c678d2d117e3c9238c35a52 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 15 Jul 2021 13:32:29 +0000 Subject: [PATCH] adding play audio action. current implementation. --- .../ActionHandling/MVMCoreActionHandler.m | 33 +++++++++++++++---- .../MVMCoreHardcodedStringsConstants.h | 1 + .../MVMCoreHardcodedStringsConstants.m | 1 + .../MVMCore/Constants/MVMCoreJSONConstants.h | 1 + .../MVMCore/Constants/MVMCoreJSONConstants.m | 1 + .../ActionType/ActionContactModel.swift | 2 +- .../ActionType/ActionOpenSMSModel.swift | 2 +- .../Strings/en.lproj/Localizable.strings | 2 ++ .../Strings/es-MX.lproj/Localizable.strings | 3 ++ .../Strings/es.lproj/Localizable.strings | 3 ++ 10 files changed, 41 insertions(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 15fab4e..4f307f5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -293,20 +293,41 @@ NSString * const KeyActionTypeOpen = @"openPage"; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; }]; } else if ([approach isEqualToString:KeyCreate]) { + contact.givenName = [actionInformation string:@"firstName"]; + contact.familyName = [actionInformation string:@"lastName"]; [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]; }]; + } else if ([approach isEqualToString:KeyView]) { + NSCharacterSet *symbols = [NSCharacterSet characterSetWithCharactersInString:@".+()-  "]; + NSString *contactPhoneNumber = [actionInformation string:@"phoneNumber"]; + contactPhoneNumber = [[contactPhoneNumber componentsSeparatedByCharactersInSet:symbols] componentsJoinedByString:@""]; + CNPhoneNumber *number = [[CNPhoneNumber alloc] initWithStringValue:contactPhoneNumber]; + NSPredicate *contactPredicate = [CNContact predicateForContactsMatchingPhoneNumber:number]; + NSArray *displayedKeys = @[[CNContactViewController descriptorForRequiredKeys]]; + CNContactStore *store = [[CNContactStore alloc] init]; + NSError *error; + CNContact *viewContact = [[store unifiedContactsMatchingPredicate:contactPredicate keysToFetch:displayedKeys error:&error] firstObject]; + + if (viewContact) { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:viewContact]; + controller.contactStore = store; + controller.delegate = weakSelf; + + [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; + }]; + } else { + // No contacts found, show an alert + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorContactUnAvailable] code:ErrorCodeDefault domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeContact]]; + error.silentError = NO; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } } } diff --git a/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.h b/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.h index d669629..6fc12d4 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.h @@ -15,3 +15,4 @@ extern NSString * const HardcodedOK; extern NSString * const HardcodedErrorCritical; extern NSString * const HardcodedErrorUnableToProcess; +extern NSString * const HardcodedErrorContactUnAvailable; diff --git a/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.m b/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.m index e6c17f3..136b84e 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreHardcodedStringsConstants.m @@ -15,3 +15,4 @@ NSString * const HardcodedOK = @"okCaps"; NSString * const HardcodedErrorCritical = @"Error Message Critical Key"; NSString * const HardcodedErrorUnableToProcess = @"Error Message Unable To Process Request Key"; +NSString * const HardcodedErrorContactUnAvailable = @"Contact not available"; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index 084db36..2fdc9de 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -28,6 +28,7 @@ extern NSString * const KeyPostAction; extern NSString * const KeyAdd; extern NSString * const KeyCreate; +extern NSString * const KeyView; extern NSString * const KeyLinks; extern NSString * const KeyTitle; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index dfd33b9..772fd05 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -30,6 +30,7 @@ NSString * const KeyPostAction = @"PostAction"; NSString * const KeyAdd = @"add"; NSString * const KeyCreate = @"create"; +NSString * const KeyView = @"view"; NSString * const KeyLinks = @"Links"; NSString * const KeyTitle = @"title"; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index 6ccbc13..f473042 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -15,7 +15,7 @@ import ContactsUI //-------------------------------------------------- public static var identifier: String = "contact" - public var actionType: String = ActionCallModel.identifier + public var actionType: String = ActionContactModel.identifier public var phoneNumber: String public var firstName: String? diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift index 60ee1ba..ead5d68 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift @@ -13,7 +13,7 @@ //-------------------------------------------------- public static var identifier: String = "sms" - public var actionType: String = ActionCallModel.identifier + public var actionType: String = ActionOpenSMSModel.identifier public var phoneNumber: String public var message: String? diff --git a/MVMCore/MVMCore/Strings/en.lproj/Localizable.strings b/MVMCore/MVMCore/Strings/en.lproj/Localizable.strings index dd2d461..6416586 100644 --- a/MVMCore/MVMCore/Strings/en.lproj/Localizable.strings +++ b/MVMCore/MVMCore/Strings/en.lproj/Localizable.strings @@ -13,3 +13,5 @@ "Error Message Critical Key" = "Unable to process your request at this time. Please contact Customer Service by dialing *611. Thank you."; "Error Message Unable To Process Request Key" = "Unable to process your request. Please try again later."; +//Fios +"Contact not available" = "Contact not available"; diff --git a/MVMCore/MVMCore/Strings/es-MX.lproj/Localizable.strings b/MVMCore/MVMCore/Strings/es-MX.lproj/Localizable.strings index 39929b7..e70b6f2 100644 --- a/MVMCore/MVMCore/Strings/es-MX.lproj/Localizable.strings +++ b/MVMCore/MVMCore/Strings/es-MX.lproj/Localizable.strings @@ -12,3 +12,6 @@ "Error Message Critical Key" = "En este momento no podemos procesar tu solicitud. Comunícate con Servicio al Cliente marcando *611. Muchas gracias."; "Error Message Unable To Process Request Key" = "No podemos procesar tu solicitud. Vuelve a intentarlo más tarde."; + +//Fios +"Contact not available" = "Contacto no disponible"; diff --git a/MVMCore/MVMCore/Strings/es.lproj/Localizable.strings b/MVMCore/MVMCore/Strings/es.lproj/Localizable.strings index 39929b7..e70b6f2 100644 --- a/MVMCore/MVMCore/Strings/es.lproj/Localizable.strings +++ b/MVMCore/MVMCore/Strings/es.lproj/Localizable.strings @@ -12,3 +12,6 @@ "Error Message Critical Key" = "En este momento no podemos procesar tu solicitud. Comunícate con Servicio al Cliente marcando *611. Muchas gracias."; "Error Message Unable To Process Request Key" = "No podemos procesar tu solicitud. Vuelve a intentarlo más tarde."; + +//Fios +"Contact not available" = "Contacto no disponible";