From 8415c0f3f5fd0fb9ec6ea040b6dac9e24e1ee478 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 14:47:15 -0400 Subject: [PATCH 001/150] more accessibility stuff. --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 992a06ee8d004da4ca42c0948ea6329e8962a474 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 1 Jul 2020 21:08:28 -0400 Subject: [PATCH 002/150] return --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 147a237ba96860503f1bb810c6e41f55085ddad5 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 30 Oct 2020 14:10:14 -0400 Subject: [PATCH 003/150] enhance controller registration to allow for configuration --- ...VMCoreViewControllerProgrammaticMappingObject.h | 4 ++++ ...VMCoreViewControllerProgrammaticMappingObject.m | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index 02487e0..fc03b06 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -13,7 +13,11 @@ // View Controller Class, for loading by class. @property (nonnull, strong, nonatomic) Class viewControllerClass; +@property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull); + // Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; +- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; + @end diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m index 8547285..a47a583 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m @@ -19,8 +19,20 @@ return self; } +- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^)(UIViewController * _Nonnull))configureBlock { + self = [self initWithClass:viewControllerClass]; + if (self) { + self.configureHandler = configureBlock; + } + return self; +} + - (nullable UIViewController *)createViewController { - return [[self.viewControllerClass alloc] init]; + UIViewController *newController = [[self.viewControllerClass alloc] init]; + if (self.configureHandler) { + self.configureHandler(newController); + } + return newController; } @end From cc2783d3be503f03570d346fb0ea3ff37c18b8f2 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 3 Nov 2020 10:03:36 -0500 Subject: [PATCH 004/150] add comments --- .../MVMCoreViewControllerProgrammaticMappingObject.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index fc03b06..b755710 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -10,14 +10,16 @@ @interface MVMCoreViewControllerProgrammaticMappingObject : NSObject -// View Controller Class, for loading by class. +/// View Controller Class, for loading by class. @property (nonnull, strong, nonatomic) Class viewControllerClass; +/// Configuration block executed on creation of the controller before loading. @property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull); -// Initializes with the given class. +/// Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; +/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuraiton of the view controller before its loaded, i.e. injecting top level dependencies. - (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; @end From d62916510ae3b5b6a91005fba07475b9e23697d5 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 3 Nov 2020 12:11:43 -0500 Subject: [PATCH 005/150] typo --- .../MVMCoreViewControllerProgrammaticMappingObject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index b755710..de0f25f 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -19,7 +19,7 @@ /// Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; -/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuraiton of the view controller before its loaded, i.e. injecting top level dependencies. +/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuration of the view controller before its loaded, i.e. injecting top level dependencies. - (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; @end From e3b089c294addb28c1fdb703d21d8a64eeda39b5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 09:56:00 -0500 Subject: [PATCH 006/150] Change to check no content errors --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 3231d11..3b244a7 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,8 +167,15 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else { + } else if ([MVMCoreLoadRequestOperation hasSomethingToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + + // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; + } else { + + // Error, foreground request with no page, alert, action, or anything else to show. Abort with error. + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; + [MVMCoreLoadRequestOperation loadAbortedWithError:error loadObject:loadObject]; } }]; }]; @@ -725,6 +732,10 @@ }]; } ++ (BOOL)hasSomethingToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { + return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; +} + + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable { if ([loadObject.operation checkAndHandleForCancellation]) { From 03152f9f8b7b8e8690072593e34c0bf40b02736b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 09:57:42 -0500 Subject: [PATCH 007/150] Changed method name --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h | 3 +++ MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index 17b6d1e..22b8cb9 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -88,6 +88,9 @@ // Displays the view controller to the screen. + (void)displayViewController:(nonnull UIViewController *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; +/// Checks to see if the operation has content to show. ++ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; + // Handles the error based on the error object passed in. May log and/or display the error. + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 3b244a7..e1b4e78 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,7 +167,7 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else if ([MVMCoreLoadRequestOperation hasSomethingToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + } else if ([MVMCoreLoadRequestOperation hasContentToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; @@ -732,7 +732,7 @@ }]; } -+ (BOOL)hasSomethingToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { ++ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; } From e3422124f59a49f35f2eb32c7a53f1a75d403d85 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 11:03:32 -0500 Subject: [PATCH 008/150] Review changes --- MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h | 1 + MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m | 1 + .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h | 6 +++--- .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 8 ++------ MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h | 3 +++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index 90f1854..f3d84ac 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -24,6 +24,7 @@ extern NSString * const KeyPageMap; extern NSString * const KeySystemParameters; extern NSString * const KeyButtonMap; extern NSString * const KeyOpenSupport; +extern NSString * const KeyPostAction; extern NSString * const KeyLinks; extern NSString * const KeyTitle; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index ac69a76..71cccac 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -26,6 +26,7 @@ NSString * const KeyPageMap = @"PageMap"; NSString * const KeySystemParameters = @"SystemParams"; NSString * const KeyButtonMap = @"ButtonMap"; NSString * const KeyOpenSupport = @"openSupport"; +NSString * const KeyPostAction = @"PostAction"; NSString * const KeyLinks = @"Links"; NSString * const KeyTitle = @"title"; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index 22b8cb9..158b991 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -26,6 +26,9 @@ @property (nonatomic) BOOL backgroundLoad; @property (nonatomic, getter=areDependenciesAdded) BOOL dependenciesAdded; +/// Legacy flag for if this operation will have an alert to show when finished. +@property (nonatomic, readonly) BOOL alertToShow; + // Initializes the operation with the request parameters object, data for page, and mvm view controller to handle the loading with. - (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegateObject:(nullable DelegateObject *)delegateObject backgroundLoad:(BOOL)backgroundLoad; @@ -88,9 +91,6 @@ // Displays the view controller to the screen. + (void)displayViewController:(nonnull UIViewController *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; -/// Checks to see if the operation has content to show. -+ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; - // Handles the error based on the error object passed in. May log and/or display the error. + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index e1b4e78..54e6f20 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -34,7 +34,7 @@ @property (weak, nonatomic) NSURLSessionTask *sessionTask; // For temporarily storing any alert to show until we determine it's delegate. -@property (nonatomic) BOOL alertToShow; +@property (nonatomic, readwrite) BOOL alertToShow; @property (strong, nonatomic, nullable) MVMCoreErrorObject *errorForAlertToShow; @end @@ -167,7 +167,7 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else if ([MVMCoreLoadRequestOperation hasContentToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + } else if (loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad || ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(hasContentToShow:error:)] && [[MVMCoreObject sharedInstance].globalLoadDelegate hasContentToShow:loadObject error:error])) { // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; @@ -732,10 +732,6 @@ }]; } -+ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { - return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; -} - + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable { if ([loadObject.operation checkAndHandleForCancellation]) { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index 027d6b7..65ea153 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -38,4 +38,7 @@ // Shows the appropriate alert style for the given response info and/or error. - (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; +/// Checks to see if the operation has content to show. +- (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; + @end From dc16cfecd4ee4d0f9415ef2a92e22318462965f6 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 19 Nov 2020 09:17:01 -0500 Subject: [PATCH 009/150] excluding architecture arm64 --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index fc17f77..5d06f8b 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -906,6 +906,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -967,6 +968,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; From 57f5bd94aa28c255edd60dedf3a9bd54d0aeb8ff Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 2 Dec 2020 11:40:36 -0500 Subject: [PATCH 010/150] updates made. --- .../MVMCore/Models/ActionType/ActionModelProtocol.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift index a5d3229..028af05 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionModelProtocol.swift @@ -12,12 +12,18 @@ public protocol ActionModelProtocol: ModelProtocol { var actionType: String { get } var extraParameters: JSONValueDictionary? { get set } var analyticsData: JSONValueDictionary? { get set } + var accessibilityIdentifier: String? { get set } } public extension ActionModelProtocol { var actionType: String { - get { return Self.identifier } + get { Self.identifier } + } + + var accessibilityIdentifier: String? { + get { nil } + set { } } static var categoryCodingKey: String { From 2eb5cc9254664d105551d63c69db7bbc0ac65596 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 3 Dec 2020 14:22:05 -0500 Subject: [PATCH 011/150] formatting updates. Adding identifier for easier testing. --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 68f5e734d8cadbd001aa6f0537f916e0874c19d8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 8 Dec 2020 14:49:47 -0500 Subject: [PATCH 012/150] keep alive on all user touches --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 54e6f20..966700a 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -149,7 +149,6 @@ if (!requestForMissingData) { // We have all the needed data, continue with the load. - [[MVMCoreSessionTimeHandler sharedSessionHandler] sendKeepAliveToServer:NO]; [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:nil]; } else { From e1ecf38ce9fdc3d0dbafa554b7b5b27d72beadb3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 14 Dec 2020 14:35:37 -0500 Subject: [PATCH 013/150] check before keep alive. --- MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.h | 6 ++++++ MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.h b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.h index bcc06db..d31ae62 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.h +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.h @@ -16,6 +16,12 @@ // The time that we started the last session timer. @property (assign, nonatomic, readonly) NSTimeInterval timeTimerStarted; +// Keeps track of if the session is currently being timed. Used for entering from the background. +@property (assign, nonatomic, readonly) BOOL sessionBeingTimed; + +// Keeps track of if the session has already timed out. +@property (assign, nonatomic, readonly) BOOL sessionTimedOut; + #pragma mark - functions to override // Can override to provide a time until the warning shows in seconds. Set to 0 if there should be no warning. Default is 0 diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m index d297d72..0a81b45 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m @@ -27,10 +27,10 @@ @property (assign, nonatomic, readwrite) NSTimeInterval timeTimerStarted; // Keeps track of if the session is currently being timed. Used for entering from the background. -@property (assign, nonatomic) BOOL sessionBeingTimed; +@property (assign, nonatomic, readwrite) BOOL sessionBeingTimed; // Keeps track of if the session has already timed out. -@property (assign, nonatomic) BOOL sessionTimedOut; +@property (assign, nonatomic, readwrite) BOOL sessionTimedOut; @property (assign, nonatomic) NSTimeInterval secondsUntilWarning; @property (assign, nonatomic) NSTimeInterval secondsUntilTimeout; From 85401e583d2294a67a4762e2701786c4d4089e54 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 15 Dec 2020 14:56:18 -0500 Subject: [PATCH 014/150] added script to improve test page access and separate from release compilation. Formatting updates. --- .../MFHardCodedServerResponse.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m index e32ec74..ed2feee 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.m @@ -69,16 +69,16 @@ - (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request { NSDictionary *cannedResponse = nil; - if(_jsonDictionary) { + if (_jsonDictionary) { BOOL matchesQuery = NO; - for(NSString *urlKey in _sortedKeys) { + for (NSString *urlKey in _sortedKeys) { NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:urlKey]; - if([urlComponents.path isEqualToString:request.pageType]) { + if ([urlComponents.path isEqualToString:request.pageType]) { matchesQuery = YES; - if(urlComponents.query) { - for(NSURLQueryItem *item in urlComponents.queryItems) { + if (urlComponents.query) { + for (NSURLQueryItem *item in urlComponents.queryItems) { NSString *requestVal = [request.parameters stringForKey:item.name]; - if(!requestVal || ![requestVal isEqualToString:item.value]) { + if (!requestVal || ![requestVal isEqualToString:item.value]) { matchesQuery = NO; break; } @@ -88,7 +88,7 @@ cannedResponse = _jsonDictionary[urlKey]; // keep searching to see if there is a more exact match on parameters } - if(matchesQuery) { + if (matchesQuery) { cannedResponse = _jsonDictionary[urlKey]; // found a request parameters match, accept as the best result and break out break; @@ -101,7 +101,6 @@ cannedResponse = [self getHardCodedResponseForPageType:request.pageType]; } - return cannedResponse; } From cd1734b62d62e85744da88db419889ab271370d7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 17 Dec 2020 10:43:41 -0500 Subject: [PATCH 015/150] server support --- .../Session/MVMCoreSessionTimeHandler.m | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m index 0a81b45..f0bf1b5 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m @@ -21,6 +21,7 @@ @interface MVMCoreSessionTimeHandler () +@property (strong, nonatomic) NSTimer *sessionWarningTimer; @property (strong, nonatomic) NSTimer *sessionTimer; // The time that we started the last session timer. @@ -74,13 +75,6 @@ } - (void)sessionTimeoutWarning { - - // Starts the timeout timer - if (!fequal(0, self.secondsUntilTimeout)) { - self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:self.secondsUntilTimeout target:self selector:@selector(sessionTimeout:) userInfo:nil repeats:NO]; - } else { - [self stopSessionTimer]; - } } - (void)sessionTimeout:(BOOL)whileInBackground { @@ -98,22 +92,22 @@ if (!self.sessionTimedOut) { + [self.sessionWarningTimer invalidate]; [self.sessionTimer invalidate]; self.secondsUntilWarning = [self timeUntilWarning]; self.secondsUntilTimeout = [self timeUntilTimeout]; - if (!fequal(0, self.secondsUntilWarning) || !fequal(0, self.secondsUntilTimeout)) { + if (!fequal(0, self.secondsUntilTimeout)) { self.sessionBeingTimed = YES; self.timeTimerStarted = [NSDate timeIntervalSinceReferenceDate]; } // Only start physical timer if active, otherwise will begin once entering foreground. - if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive && !fequal(0, self.secondsUntilTimeout)) { if (!fequal(0, self.secondsUntilWarning)) { - self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:self.secondsUntilWarning target:self selector:@selector(sessionTimeoutWarning) userInfo:nil repeats:NO]; - } else if (!fequal(0, self.secondsUntilTimeout)) { - self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:self.secondsUntilTimeout target:self selector:@selector(sessionTimeout:) userInfo:nil repeats:NO]; + self.sessionWarningTimer = [NSTimer scheduledTimerWithTimeInterval:self.secondsUntilWarning target:self selector:@selector(sessionTimeoutWarning) userInfo:nil repeats:NO]; } + self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:self.secondsUntilTimeout target:self selector:@selector(sessionTimeout:) userInfo:nil repeats:NO]; } } }); @@ -124,6 +118,8 @@ // nil timer, session no longer timed. dispatch_async(dispatch_get_main_queue(), ^(void) { self.sessionBeingTimed = NO; + [self.sessionWarningTimer invalidate]; + self.sessionWarningTimer = nil; [self.sessionTimer invalidate]; self.sessionTimer = nil; }); @@ -133,6 +129,8 @@ // Session is still being timed. Invalidates here, will start up again on enter foreground if need be. dispatch_async(dispatch_get_main_queue(), ^(void) { + [self.sessionWarningTimer invalidate]; + self.sessionWarningTimer = nil; [self.sessionTimer invalidate]; self.sessionTimer = nil; }); @@ -143,22 +141,25 @@ if (self.sessionBeingTimed || self.sessionTimedOut) { NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; - if ((!fequal(0, self.secondsUntilWarning) && now > self.timeTimerStarted + self.secondsUntilWarning) || (fequal(0, self.secondsUntilWarning) && !fequal(0, self.secondsUntilTimeout) && now > self.timeTimerStarted + self.secondsUntilTimeout)) { + if ((!fequal(0, self.secondsUntilWarning) && now > self.timeTimerStarted + self.secondsUntilWarning) || (!fequal(0, self.secondsUntilTimeout) && now > self.timeTimerStarted + self.secondsUntilTimeout)) { // Timeout if we are passed the warning. [self sessionTimeout:YES]; - } else if (!fequal(0, self.secondsUntilWarning)) { + } else { + if (!fequal(0, self.secondsUntilWarning)) { - // Restart the warning timer! - NSTimeInterval timeLeftTillWarning = self.timeTimerStarted + self.secondsUntilWarning - now; - [self.sessionTimer invalidate]; - self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:timeLeftTillWarning target:self selector:@selector(sessionTimeoutWarning) userInfo:nil repeats:NO]; - } else if (!fequal(0, self.secondsUntilTimeout)) { + // Restart the warning timer! + NSTimeInterval timeLeftTillWarning = self.timeTimerStarted + self.secondsUntilWarning - now; + [self.sessionWarningTimer invalidate]; + self.sessionWarningTimer = [NSTimer scheduledTimerWithTimeInterval:timeLeftTillWarning target:self selector:@selector(sessionTimeoutWarning) userInfo:nil repeats:NO]; + } + if (!fequal(0, self.secondsUntilTimeout)) { - // Restart the timeout timer! - NSTimeInterval timeLeftTillTimeout = self.timeTimerStarted + self.secondsUntilTimeout - now; - [self.sessionTimer invalidate]; - self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:timeLeftTillTimeout target:self selector:@selector(sessionTimeout:) userInfo:nil repeats:NO]; + // Restart the timeout timer! + NSTimeInterval timeLeftTillTimeout = self.timeTimerStarted + self.secondsUntilTimeout - now; + [self.sessionTimer invalidate]; + self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:timeLeftTillTimeout target:self selector:@selector(sessionTimeout:) userInfo:nil repeats:NO]; + } } } } @@ -174,6 +175,8 @@ NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; if ((!fequal(0, self.secondsUntilWarning) && now > self.timeTimerStarted + self.secondsUntilWarning) || (!fequal(0, self.secondsUntilTimeout) && now > self.timeTimerStarted + self.secondsUntilTimeout)) { self.sessionTimedOut = YES; + [self.sessionWarningTimer invalidate]; + self.sessionWarningTimer = nil; [self.sessionTimer invalidate]; self.sessionTimer = nil; } else if (![self.sessionTimer isValid]) { From a5960728c4503f6947173ae51f4600c10942c877 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 5 Jan 2021 22:26:21 -0500 Subject: [PATCH 016/150] WIP: basic implmentation --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 32 ++++ .../ActionHandler+ClientParameters.swift | 41 +++++ .../ActionHandling/MVMCoreActionHandler.m | 140 +++++++++++------- .../ActionType/ActionOpenPageModel.swift | 5 +- .../ActionType/ActionOpenUrlModel.swift | 3 +- .../ClientParameterActionProtocol.swift | 13 ++ .../ClientParameterModel.swift | 31 ++++ .../ClientParameterModelProtocol.swift | 29 ++++ .../ClientParameterProtocol.swift | 35 +++++ .../ClientParameterRegistry.swift | 79 ++++++++++ .../MVMCore/Session/MVMCoreSessionObject.m | 1 + .../MFHardCodedServerResponse.h | 2 +- 12 files changed, 354 insertions(+), 57 deletions(-) create mode 100644 MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index fc17f77..aa096b4 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -21,6 +21,12 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 016FF6EE259A4E6300F5E4AA /* ClientParameterModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */; }; + 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */; }; + 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */; }; + 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */; }; + 016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */; }; + 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; }; 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; }; @@ -144,6 +150,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModelProtocol.swift; sourceTree = ""; }; + 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModel.swift; sourceTree = ""; }; + 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = ""; }; + 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterProtocol.swift; sourceTree = ""; }; + 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActionHandler+ClientParameters.swift"; sourceTree = ""; }; + 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; 01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = ""; }; 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = ""; }; @@ -286,6 +298,18 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 016FF6EC259A4E3E00F5E4AA /* Client Parameters */ = { + isa = PBXGroup; + children = ( + 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */, + 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */, + 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */, + 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */, + 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */, + ); + path = "Client Parameters"; + sourceTree = ""; + }; 8876D5BF1FB50A9E00EB2E3D = { isa = PBXGroup; children = ( @@ -405,6 +429,7 @@ 946EE1B6237B66630036751F /* ActionType */ = { isa = PBXGroup; children = ( + 016FF6EC259A4E3E00F5E4AA /* Client Parameters */, 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */, 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, @@ -560,6 +585,7 @@ AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */, AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */, AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */, + 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */, ); path = ActionHandling; sourceTree = ""; @@ -784,6 +810,7 @@ buildActionMask = 2147483647; files = ( AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */, + 016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */, 946EE1A7237B5B1C0036751F /* ModelRegistry.swift in Sources */, AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */, AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */, @@ -820,6 +847,7 @@ AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */, 8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */, 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */, + 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */, AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */, AFED77A61FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.m in Sources */, @@ -830,6 +858,7 @@ 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */, AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */, AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */, + 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */, 94C014D924212360005811A9 /* ActionSettingModel.swift in Sources */, D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */, 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */, @@ -845,10 +874,13 @@ AFBB96941FBA3A9A0008D868 /* MVMCorePresentAnimationOperation.m in Sources */, 94C014D524211AF0005811A9 /* ActionCancelModel.swift in Sources */, AF43A5841FBB66DE008E9347 /* MVMCoreConstants.m in Sources */, + 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */, D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */, AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, + 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */, 8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */, D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */, + 016FF6EE259A4E6300F5E4AA /* ClientParameterModelProtocol.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift new file mode 100644 index 0000000..fbbb8ca --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -0,0 +1,41 @@ +// +// ActionHandler+ClientParameters.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/30/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + +//- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { +// +// NSString *action = [dictionary stringForKey:KeyActionType]; +// [self handleAction:action actionInformation:dictionary additionalData:additionalData delegate:delegate]; +//} + +public extension MVMCoreActionHandler { + + @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { + + guard let paramsList = actionMap?.optionalArrayForChainOfKeysOrIndexes(["clientParameters", "list"]) as? [[String : Any]] else { + completionHandler(actionMap) + return + } + + MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() + ClientParameterRegistry.injectParams(with: paramsList) { (clientParams) in + guard let clientParams = clientParams else { + completionHandler(actionMap) + return + } + var extraParams:[String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] + extraParams.merge(clientParams) { (_, new) in new } + var actionMapM = actionMap + actionMapM?[KeyExtraParameters] = extraParams + + MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true) + completionHandler(actionMapM) + } + } +} diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index ee539d0..68cfc07 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -107,22 +107,28 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Loads the given page type. NSString *pageType = [actionInformation stringForKey:KeyPageType]; - if (pageType.length > 0) { - MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; - - [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { + + if (pageType.length == 0) { + // No page type to load, show error. + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeOpen]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; + return; + } + + __weak typeof(self) weakSelf = self; + void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { + MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionMap]; + + [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; } else { [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegateObject:delegateObject]; } }]; - } else { - - // No page type to load, show error. - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeOpen]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + }; + + [self preprocessRequest:actionInformation actionBlock:performAction]; } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -266,23 +272,28 @@ NSString * const KeyActionTypeOpen = @"openPage"; #pragma mark - open url functions - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - // Gets the app url - NSURL *appURL = nil; - NSString *appURLString = [actionInformation string:KeyLinkAwayAppURL]; - if (appURLString.length > 0) { - appURL = [NSURL URLWithString:appURLString]; - } - - // Gets the browser url - NSURL *otherURL = nil; - NSString *otherURLString = [actionInformation string:KeyLinkAwayURL]; - if (otherURLString.length > 0) { - otherURL = [NSURL URLWithString:otherURLString]; - } - - // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + __weak typeof(self) weakSelf = self; + void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { + // Gets the app url + NSURL *appURL = nil; + NSString *appURLString = [actionMap string:KeyLinkAwayAppURL]; + if (appURLString.length > 0) { + appURL = [NSURL URLWithString:appURLString]; + } + + // Gets the browser url + NSURL *otherURL = nil; + NSString *otherURLString = [actionMap string:KeyLinkAwayURL]; + if (otherURLString.length > 0) { + otherURL = [NSURL URLWithString:otherURLString]; + } + + // Provide the URL and App URL to be modified if needed by a subclass or delegate. + [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; + }; + + [self preprocessRequest:actionInformation actionBlock:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -411,21 +422,39 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Loads the given page type. NSString *pageType = [actionInformation stringForKey:KeyPageType]; - if (pageType.length > 0) { - MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; - - [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { + + if (pageType.length == 0) { + // No page type to load, show error. + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeOpen]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; + return; + } + + __weak typeof(self) weakSelf = self; + void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { + MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionMap]; + + [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { - [delegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; + [delegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionMap additionalData:additionalData]; } else { [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegate:delegate]; } }]; + }; + + [self preprocessRequest:actionInformation actionBlock:performAction]; +} + +- (void)preprocessRequest:(nullable NSDictionary *)actionInformation actionBlock:(nullable void (^)(NSDictionary*))actionBlock { + // Check for client params and fetch the parameters + if ([actionInformation dict:@"clientParameters"]) { + [self setClientParameterWith:actionInformation + completionHandler:^(NSDictionary * _Nullable actionDict) { + actionBlock(actionDict); + }]; } else { - - // No page type to load, show error. - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeOpen]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; + actionBlock(actionInformation); } } @@ -524,23 +553,28 @@ NSString * const KeyActionTypeOpen = @"openPage"; } - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - // Gets the app url - NSURL *appURL = nil; - NSString *appURLString = [actionInformation string:KeyLinkAwayAppURL]; - if (appURLString.length > 0) { - appURL = [NSURL URLWithString:appURLString]; - } - - // Gets the browser url - NSURL *otherURL = nil; - NSString *otherURLString = [actionInformation string:KeyLinkAwayURL]; - if (otherURLString.length > 0) { - otherURL = [NSURL URLWithString:otherURLString]; - } - - // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionInformation additionalData:additionalData delegate:delegate]; + + __weak typeof(self) weakSelf = self; + void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { + // Gets the app url + NSURL *appURL = nil; + NSString *appURLString = [actionMap string:KeyLinkAwayAppURL]; + if (appURLString.length > 0) { + appURL = [NSURL URLWithString:appURLString]; + } + + // Gets the browser url + NSURL *otherURL = nil; + NSString *otherURLString = [actionMap string:KeyLinkAwayURL]; + if (otherURLString.length > 0) { + otherURL = [NSURL URLWithString:otherURLString]; + } + + // Provide the URL and App URL to be modified if needed by a subclass or delegate. + [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; + }; + + [self preprocessRequest:actionInformation actionBlock:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 40e7312..52af9f0 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -7,7 +7,7 @@ // -@objcMembers open class ActionOpenPageModel: ActionModelProtocol { +@objcMembers open class ActionOpenPageModel: ActionModelProtocol, ClientParameterActionProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -20,7 +20,8 @@ public var presentationStyle: String? public var tabBarIndex: Int? public var background: Bool? - + public var clientParameterModel: ClientParameterModel? + //-------------------------------------------------- // MARK: - Initialzier //-------------------------------------------------- diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index 03a1e95..998716b 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -7,7 +7,7 @@ // -@objcMembers public class ActionOpenUrlModel: ActionModelProtocol { +@objcMembers public class ActionOpenUrlModel: ActionModelProtocol, ClientParameterActionProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -30,6 +30,7 @@ public var dontShowProgress: Bool? public var headerParameters: JSONValueDictionary? public var enableNativeScroll: Bool? + public var clientParameterModel: ClientParameterModel? //-------------------------------------------------- // MARK: - Initialzier diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift new file mode 100644 index 0000000..51fb71a --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift @@ -0,0 +1,13 @@ +// +// ClientParameterActionProtocol.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 1/5/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + +public protocol ClientParameterActionProtocol { + var clientParameterModel: ClientParameterModel? { get set } +} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift new file mode 100644 index 0000000..8686d71 --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift @@ -0,0 +1,31 @@ +// +// ClientParameterModel.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/28/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + +public class ClientParameterModel: Codable { + var timeout: Double? + var list: [ClientParameterModelProtocol] + + private enum CodingKeys: String, CodingKey { + case timeout + case list + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + timeout = try typeContainer.decodeIfPresent(Double.self, forKey: .timeout) + list = try typeContainer.decodeModels(codingKey: .list) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(timeout, forKey: .timeout) + try container.encodeModels(list, forKey: .list) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift new file mode 100644 index 0000000..2dd6731 --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift @@ -0,0 +1,29 @@ +// +// ClientParameterProtocol.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/28/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + +public protocol ClientParameterModelProtocol: ModelProtocol { + var type: String { get } + var inputParameters: JSONValueDictionary? { get set } +} + +public extension ClientParameterModelProtocol { + + var type: String { + get { Self.identifier } + } + + static var categoryCodingKey: String { + return "type" + } + + static var categoryName: String { + return "\(ClientParameterModelProtocol.self)" + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift new file mode 100644 index 0000000..5f36f30 --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -0,0 +1,35 @@ +// +// ClientParameterProtocol.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/29/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + +public protocol ClientParameterProtocol { + init() + static var name: String { get } + func clientParameter(with paramModel: ClientParameterModelProtocol?) -> [String: Any]? +} + +extension ClientParameterProtocol { + /// Handle encoding and errors + public func getJSON(with paramModel: ClientParameterModelProtocol?) -> JSONDictionary? { + guard let dataModel = paramModel, + let json = dataModel.toJSON() else { + // JSON parsing failed + if let errorObject = MVMCoreErrorObject(title: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorTitle), + message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), + messageToLog: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), + code: ErrorCode.parsingJSON.rawValue, + domain: ErrorDomainNative, + location: String(describing: Self.name)) { + //MFLoggingHandler.addError(toLog: errorObject) + } + return nil + } + return json + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift new file mode 100644 index 0000000..be0285e --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -0,0 +1,79 @@ +// +// ClientParameterRegistry.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 12/29/20. +// Copyright © 2020 myverizon. All rights reserved. +// + +import Foundation + + +@objcMembers open class ClientParameterRegistry: NSObject { + + public static let shared = ClientParameterRegistry() + private var mapping: [String: ClientParameterProtocol.Type] = [:] + + public func register(param: T.Type) { + mapping[T.name] = param + } + + public func createParam(_ actionType: String) -> ClientParameterProtocol? { + guard let patamType = mapping[actionType] else { return nil } + return patamType.init() + } + + static func injectParams(with paramsModelList: [[String: Any]]?, + completionHandler:@escaping ([String: Any]?) -> ()) { + + let clientParameterRegistry = ClientParameterRegistry.shared + guard let paramsModelList = paramsModelList else { + completionHandler(nil) + return + } + + var paramsList: [String: Any] = [:] + MVMCoreDispatchUtility.performSyncBlock( inBackground: { () -> Void in + for param in paramsModelList { + if let clientParam = clientParameterRegistry.injectParam(param) { + paramsList.merge(clientParam) { (_, new) in new } + } + } + }) + completionHandler(paramsList) + print("") + } + + func injectParam( _ param: [String: Any]) -> [String: Any]? { + if let paramModel = try? ClientParameterRegistry.getModel(param), + let param = ClientParameterRegistry.shared.createParam(paramModel.type) { + return param.clientParameter(with: paramModel) + } + return nil + } + + + /// Add all registry here. + public static func registerParameters() { + + } + + /// Register Default Core Bridge Objects + public static func register(parameter: T.Type, type: M.Type) { + try? ModelRegistry.register(type) + ClientParameterRegistry.shared.register(param: parameter) + } + + public static func getModel(_ json: [String: Any]) throws -> ClientParameterModelProtocol { + guard let paramType = json.optionalStringForKey("type") else { + throw ModelRegistry.Error.other(message: "parameterType missing") + } + guard let type = ModelRegistry.getType(for: paramType, with: ClientParameterModelProtocol.self) else { + throw ModelRegistry.Error.decoderErrorModelNotMapped() + } + guard let model = try type.decode(jsonDict: json) as? ClientParameterModelProtocol else { + throw ModelRegistry.Error.decoderError + } + return model + } +} diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m index 7134c59..8650972 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m @@ -17,6 +17,7 @@ if (self = [super init]) { self.session = [self createNSURLSession]; [ModelMapping registerObjects]; + [ClientParameterRegistry registerParameters]; } return self; } diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From d49111766bb8275b35413b05532ef03b05f0fe73 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 6 Jan 2021 20:53:40 -0500 Subject: [PATCH 017/150] concurrent queue and timout --- .../ActionHandler+ClientParameters.swift | 5 +-- .../ClientParameterRegistry.swift | 36 +++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index fbbb8ca..53acc76 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -18,13 +18,14 @@ public extension MVMCoreActionHandler { @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { - guard let paramsList = actionMap?.optionalArrayForChainOfKeysOrIndexes(["clientParameters", "list"]) as? [[String : Any]] else { + guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { completionHandler(actionMap) return } MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() - ClientParameterRegistry.injectParams(with: paramsList) { (clientParams) in + + ClientParameterRegistry.injectParams(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { completionHandler(actionMap) return diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index be0285e..31fd7e0 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -23,25 +23,41 @@ import Foundation return patamType.init() } - static func injectParams(with paramsModelList: [[String: Any]]?, + static func injectParams(with clientParameters: [String: Any]?, completionHandler:@escaping ([String: Any]?) -> ()) { let clientParameterRegistry = ClientParameterRegistry.shared - guard let paramsModelList = paramsModelList else { + guard let clientParameters = clientParameters, + let paramsModelList = clientParameters.optionalArrayForKey("list") as? [[String: Any]] else { completionHandler(nil) return } var paramsList: [String: Any] = [:] - MVMCoreDispatchUtility.performSyncBlock( inBackground: { () -> Void in + + DispatchQueue.global(qos: .userInitiated).async { + + let concurrentQueue = DispatchQueue(label: "com.mva.clientparam", attributes: .concurrent) + let group = DispatchGroup() for param in paramsModelList { - if let clientParam = clientParameterRegistry.injectParam(param) { - paramsList.merge(clientParam) { (_, new) in new } + group.enter() + concurrentQueue.async(flags: .barrier) { + if let clientParam = clientParameterRegistry.injectParam(param) { + paramsList.merge(clientParam) { (_, new) in new } + } + group.leave() } } - }) - completionHandler(paramsList) - print("") + + if let timeout = clientParameters.optionalCGFloatForKey("timeout") { + let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) + _ = group.wait(timeout: .now() + dispatchAfterTime) + } else { + group.wait() + } + + completionHandler(paramsList) + } } func injectParam( _ param: [String: Any]) -> [String: Any]? { @@ -54,9 +70,7 @@ import Foundation /// Add all registry here. - public static func registerParameters() { - - } + public static func registerParameters() { } /// Register Default Core Bridge Objects public static func register(parameter: T.Type, type: M.Type) { From d65351cabb6723aa75a9317e21a69ecf4c05a1df Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 7 Jan 2021 09:59:10 -0500 Subject: [PATCH 018/150] remove hardcode --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 9538b50f84ea1e9151bd34d60421804df0676a51 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 7 Jan 2021 14:51:54 -0500 Subject: [PATCH 019/150] passing completion handler and timout --- .../ClientParameterProtocol.swift | 3 +- .../ClientParameterRegistry.swift | 37 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 5f36f30..53dd12d 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,10 +11,11 @@ import Foundation public protocol ClientParameterProtocol { init() static var name: String { get } - func clientParameter(with paramModel: ClientParameterModelProtocol?) -> [String: Any]? + func clientParameter(with paramModel: ClientParameterModelProtocol, _ timout: CGFloat?, completionHandler:@escaping ([String: Any]?) -> ()) } extension ClientParameterProtocol { + /// Handle encoding and errors public func getJSON(with paramModel: ClientParameterModelProtocol?) -> JSONDictionary? { guard let dataModel = paramModel, diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 31fd7e0..3be23bd 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -37,35 +37,40 @@ import Foundation DispatchQueue.global(qos: .userInitiated).async { + let timeout = clientParameters.optionalCGFloatForKey("timeout") ?? 60.0 + let concurrentQueue = DispatchQueue(label: "com.mva.clientparam", attributes: .concurrent) let group = DispatchGroup() for param in paramsModelList { group.enter() - concurrentQueue.async(flags: .barrier) { - if let clientParam = clientParameterRegistry.injectParam(param) { - paramsList.merge(clientParam) { (_, new) in new } + + clientParameterRegistry.injectParam(param, timeout-1) { (clientParam) in + guard let clientParam = clientParam else { + group.leave() + return + } + concurrentQueue.async(flags: .barrier) { + paramsList.merge(clientParam) { (_, new) in new } + group.leave() } - group.leave() } } - if let timeout = clientParameters.optionalCGFloatForKey("timeout") { - let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) - _ = group.wait(timeout: .now() + dispatchAfterTime) - } else { - group.wait() - } - + let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) + _ = group.wait(timeout: .now() + dispatchAfterTime) + completionHandler(paramsList) } } - func injectParam( _ param: [String: Any]) -> [String: Any]? { - if let paramModel = try? ClientParameterRegistry.getModel(param), - let param = ClientParameterRegistry.shared.createParam(paramModel.type) { - return param.clientParameter(with: paramModel) + func injectParam( _ param: [String: Any], _ timout: CGFloat, completionHandler:@escaping ([String: Any]?) -> ()) { + + guard let paramModel = try? ClientParameterRegistry.getModel(param), + let param = ClientParameterRegistry.shared.createParam(paramModel.type) else { + return completionHandler(nil) } - return nil + + param.clientParameter(with: paramModel, timout, completionHandler: completionHandler) } From e71f6cd7d7ef805c7dcac3e11445f76578ece7b6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 8 Jan 2021 17:02:10 -0500 Subject: [PATCH 020/150] timer --- .../ClientParameterRegistry.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 3be23bd..6fe5f38 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -37,10 +37,19 @@ import Foundation DispatchQueue.global(qos: .userInitiated).async { - let timeout = clientParameters.optionalCGFloatForKey("timeout") ?? 60.0 + let timeout = clientParameters.optionalCGFloatForKey("timeout") ?? 30.0 let concurrentQueue = DispatchQueue(label: "com.mva.clientparam", attributes: .concurrent) let group = DispatchGroup() + + + let completionItem = DispatchWorkItem { + completionHandler(paramsList); + } + + let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) + concurrentQueue.asyncAfter(deadline: .now() + dispatchAfterTime, execute: completionItem) + for param in paramsModelList { group.enter() @@ -55,11 +64,7 @@ import Foundation } } } - - let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) - _ = group.wait(timeout: .now() + dispatchAfterTime) - - completionHandler(paramsList) + group.notify(queue: concurrentQueue, work: completionItem); } } From 2bfca1cfcdb40fc52f2a0881fb1e7c98d5bb035d Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 11 Jan 2021 11:40:18 -0500 Subject: [PATCH 021/150] remove timer for now --- .../Client Parameters/ClientParameterRegistry.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 6fe5f38..cc98d1a 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -47,8 +47,8 @@ import Foundation completionHandler(paramsList); } - let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) - concurrentQueue.asyncAfter(deadline: .now() + dispatchAfterTime, execute: completionItem) +// let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) +// concurrentQueue.asyncAfter(deadline: .now() + dispatchAfterTime, execute: completionItem) for param in paramsModelList { group.enter() From 4805c1ed43fe21bfb7098e0621b9c43e959b40de Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 12 Jan 2021 16:36:09 -0500 Subject: [PATCH 022/150] polish, re-enable timeout --- .../ActionHandler+ClientParameters.swift | 6 -- .../ActionType/ActionOpenPageModel.swift | 2 +- .../ActionType/ActionOpenUrlModel.swift | 2 +- .../ClientParameterActionProtocol.swift | 2 +- .../ClientParameterModelProtocol.swift | 1 - .../ClientParameterProtocol.swift | 2 +- .../ClientParameterRegistry.swift | 89 +++++++++++-------- 7 files changed, 56 insertions(+), 48 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 53acc76..fe52f39 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -8,12 +8,6 @@ import Foundation -//- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { -// -// NSString *action = [dictionary stringForKey:KeyActionType]; -// [self handleAction:action actionInformation:dictionary additionalData:additionalData delegate:delegate]; -//} - public extension MVMCoreActionHandler { @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 52af9f0..a20d343 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -20,7 +20,7 @@ public var presentationStyle: String? public var tabBarIndex: Int? public var background: Bool? - public var clientParameterModel: ClientParameterModel? + public var clientParameters: ClientParameterModel? //-------------------------------------------------- // MARK: - Initialzier diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index 998716b..96e51f5 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -18,6 +18,7 @@ public var browserUrl: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? + public var clientParameters: ClientParameterModel? public var appURL: String? //TODO: Should be removed in future releases. This should be MF specific. @@ -30,7 +31,6 @@ public var dontShowProgress: Bool? public var headerParameters: JSONValueDictionary? public var enableNativeScroll: Bool? - public var clientParameterModel: ClientParameterModel? //-------------------------------------------------- // MARK: - Initialzier diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift index 51fb71a..f969a95 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterActionProtocol.swift @@ -9,5 +9,5 @@ import Foundation public protocol ClientParameterActionProtocol { - var clientParameterModel: ClientParameterModel? { get set } + var clientParameters: ClientParameterModel? { get set } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift index 2dd6731..b742170 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift @@ -10,7 +10,6 @@ import Foundation public protocol ClientParameterModelProtocol: ModelProtocol { var type: String { get } - var inputParameters: JSONValueDictionary? { get set } } public extension ClientParameterModelProtocol { diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 53dd12d..3420cf9 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,7 +11,7 @@ import Foundation public protocol ClientParameterProtocol { init() static var name: String { get } - func clientParameter(with paramModel: ClientParameterModelProtocol, _ timout: CGFloat?, completionHandler:@escaping ([String: Any]?) -> ()) + func fetchClientParameters(for paramModel: ClientParameterModelProtocol, timingOutIn timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) } extension ClientParameterProtocol { diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index cc98d1a..7cdcefa 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -14,11 +14,11 @@ import Foundation public static let shared = ClientParameterRegistry() private var mapping: [String: ClientParameterProtocol.Type] = [:] - public func register(param: T.Type) { - mapping[T.name] = param + public func register(_ handler: T.Type) { + mapping[T.name] = handler } - public func createParam(_ actionType: String) -> ClientParameterProtocol? { + public func createParamHandler(_ actionType: String) -> ClientParameterProtocol? { guard let patamType = mapping[actionType] else { return nil } return patamType.init() } @@ -34,58 +34,73 @@ import Foundation } var paramsList: [String: Any] = [:] - - DispatchQueue.global(qos: .userInitiated).async { - - let timeout = clientParameters.optionalCGFloatForKey("timeout") ?? 30.0 - - let concurrentQueue = DispatchQueue(label: "com.mva.clientparam", attributes: .concurrent) - let group = DispatchGroup() - - - let completionItem = DispatchWorkItem { + let timeout = clientParameters["timeout"] as? Double ?? 30.0 + + let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparam") + let group = DispatchGroup() + let defaultErrorString = "Failed to collect." + + // Dispatch setup on queue to ensure setup is complete before completion callbacks. + parametersWorkQueue.async(group: group, qos: .userInitiated) { + // Setup completion handlers. Barriered to ensure one happens after the other. + var complete = false + let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { completionHandler(paramsList); + complete = true } - -// let dispatchAfterTime = DispatchTimeInterval.seconds(Int(timeout)) -// concurrentQueue.asyncAfter(deadline: .now() + dispatchAfterTime, execute: completionItem) - + let completionWorkItem = DispatchWorkItem(qos: .userInitiated) { + timeoutWorkItem.cancel() + if !complete { // In the case of firing after timeout. + completionHandler(paramsList); + complete = true + } + } + + // Setup timeout. + parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) + + // Setup the parameter execution. for param in paramsModelList { - group.enter() - - clientParameterRegistry.injectParam(param, timeout-1) { (clientParam) in - guard let clientParam = clientParam else { - group.leave() - return + guard let paramModel = try? Self.getModel(param) else { + if let paramType = param.optionalStringForKey("type") { + paramsList[paramType] = ["error": "Parsing error."] } - concurrentQueue.async(flags: .barrier) { - paramsList.merge(clientParam) { (_, new) in new } - group.leave() + continue + } + // Setup default timeout / nil error. This will be replaced as parameters are collected. + paramsList[paramModel.type] = ["error": defaultErrorString] + group.enter() + // Dispatch asynchronous injection. + clientParameterRegistry.injectParam(paramModel, before: timeout) { (clientParam) in + // Queue the results for merge. + parametersWorkQueue.async { + if let clientParam = clientParam { + paramsList[paramModel.type] = clientParam + } + group.leave() // Leaving is only done after setup (barriered). } } } - group.notify(queue: concurrentQueue, work: completionItem); + + // Callback when all parameters have been merged. + group.notify(queue: parametersWorkQueue, work: completionWorkItem); } } - func injectParam( _ param: [String: Any], _ timout: CGFloat, completionHandler:@escaping ([String: Any]?) -> ()) { - - guard let paramModel = try? ClientParameterRegistry.getModel(param), - let param = ClientParameterRegistry.shared.createParam(paramModel.type) else { + func injectParam( _ paramModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) { + guard let paramHandler = ClientParameterRegistry.shared.createParamHandler(paramModel.type) else { return completionHandler(nil) } - - param.clientParameter(with: paramModel, timout, completionHandler: completionHandler) + paramHandler.fetchClientParameters(for: paramModel, timingOutIn: timeout, completionHandler: completionHandler) } - /// Add all registry here. public static func registerParameters() { } /// Register Default Core Bridge Objects - public static func register(parameter: T.Type, type: M.Type) { - try? ModelRegistry.register(type) - ClientParameterRegistry.shared.register(param: parameter) + public static func register(handler: T.Type, for model: M.Type) { + try? ModelRegistry.register(model) + ClientParameterRegistry.shared.register(handler) } public static func getModel(_ json: [String: Any]) throws -> ClientParameterModelProtocol { From 2426b626fe8e68aadbb4a55ce27b42c029f488de Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 14 Jan 2021 19:18:32 -0500 Subject: [PATCH 023/150] code review --- .../ActionHandler+ClientParameters.swift | 20 ++++- .../ActionHandling/MVMCoreActionHandler.m | 4 +- .../ClientParameterProtocol.swift | 11 +-- .../ClientParameterRegistry.swift | 75 +++++++++---------- .../MVMCore/Models/Model/ModelRegistry.swift | 16 ++++ .../MFHardCodedServerResponse.h | 2 +- 6 files changed, 73 insertions(+), 55 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index fe52f39..bbd951a 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -17,19 +17,31 @@ public extension MVMCoreActionHandler { return } - MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() + let isBackgroudRequest = actionMap?.boolForKey("background") ?? false - ClientParameterRegistry.injectParams(with: clientParameters) { (clientParams) in + if !isBackgroudRequest { + MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() + } + + let stopLoadingOverlay = {() in + if !isBackgroudRequest { + MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true) + } + } + + ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { + stopLoadingOverlay() completionHandler(actionMap) return } - var extraParams:[String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] + + var extraParams: [String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] extraParams.merge(clientParams) { (_, new) in new } var actionMapM = actionMap actionMapM?[KeyExtraParameters] = extraParams - MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true) + stopLoadingOverlay() completionHandler(actionMapM) } } diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 68cfc07..90374e5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -290,7 +290,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; + [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; [self preprocessRequest:actionInformation actionBlock:performAction]; @@ -571,7 +571,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; + [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; }; [self preprocessRequest:actionInformation actionBlock:performAction]; diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 3420cf9..a954ac4 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -21,15 +21,8 @@ extension ClientParameterProtocol { guard let dataModel = paramModel, let json = dataModel.toJSON() else { // JSON parsing failed - if let errorObject = MVMCoreErrorObject(title: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorTitle), - message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), - messageToLog: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), - code: ErrorCode.parsingJSON.rawValue, - domain: ErrorDomainNative, - location: String(describing: Self.name)) { - //MFLoggingHandler.addError(toLog: errorObject) - } - return nil + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ClientParameterProtocol JSON parsing failed") + return nil } return json } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 7cdcefa..fe91785 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -18,25 +18,35 @@ import Foundation mapping[T.name] = handler } - public func createParamHandler(_ actionType: String) -> ClientParameterProtocol? { - guard let patamType = mapping[actionType] else { return nil } - return patamType.init() + public func createParametersHandler(_ actionType: String) -> ClientParameterProtocol? { + guard let parameterType = mapping[actionType] else { return nil } + return parameterType.init() } - static func injectParams(with clientParameters: [String: Any]?, + static func getClientParameterModel(_ clientParameters: [String: Any]) -> ClientParameterModel? { + do { + let data = try JSONSerialization.data(withJSONObject: clientParameters) + return try JSONDecoder().decode(ClientParameterModel.self, from: data) + } catch { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error parsing getClientParameterModel: \(error)") + return nil + } + } + + static func injectParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) { let clientParameterRegistry = ClientParameterRegistry.shared - guard let clientParameters = clientParameters, - let paramsModelList = clientParameters.optionalArrayForKey("list") as? [[String: Any]] else { + + guard let clientParameterModel = ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) return } - var paramsList: [String: Any] = [:] - let timeout = clientParameters["timeout"] as? Double ?? 30.0 - - let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparam") + var parametersList: [String: Any] = [:] + let timeout = clientParameterModel.timeout ?? 30.0 + + let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") let group = DispatchGroup() let defaultErrorString = "Failed to collect." @@ -45,13 +55,13 @@ import Foundation // Setup completion handlers. Barriered to ensure one happens after the other. var complete = false let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { - completionHandler(paramsList); + completionHandler(parametersList); complete = true } let completionWorkItem = DispatchWorkItem(qos: .userInitiated) { timeoutWorkItem.cancel() if !complete { // In the case of firing after timeout. - completionHandler(paramsList); + completionHandler(parametersList); complete = true } } @@ -60,38 +70,33 @@ import Foundation parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) // Setup the parameter execution. - for param in paramsModelList { - guard let paramModel = try? Self.getModel(param) else { - if let paramType = param.optionalStringForKey("type") { - paramsList[paramType] = ["error": "Parsing error."] - } - continue - } + for parameterModel in clientParameterModel.list { // Setup default timeout / nil error. This will be replaced as parameters are collected. - paramsList[paramModel.type] = ["error": defaultErrorString] + parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.injectParam(paramModel, before: timeout) { (clientParam) in + clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (clientParam) in // Queue the results for merge. parametersWorkQueue.async { if let clientParam = clientParam { - paramsList[paramModel.type] = clientParam + parametersList[parameterModel.type] = clientParam } group.leave() // Leaving is only done after setup (barriered). } } } + // Callback when all parameters have been merged. group.notify(queue: parametersWorkQueue, work: completionWorkItem); } } - func injectParam( _ paramModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) { - guard let paramHandler = ClientParameterRegistry.shared.createParamHandler(paramModel.type) else { + func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) { + guard let parammeterHandler = ClientParameterRegistry.shared.createParametersHandler(parameterModel.type) else { return completionHandler(nil) } - paramHandler.fetchClientParameters(for: paramModel, timingOutIn: timeout, completionHandler: completionHandler) + parammeterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) } /// Add all registry here. @@ -99,20 +104,12 @@ import Foundation /// Register Default Core Bridge Objects public static func register(handler: T.Type, for model: M.Type) { - try? ModelRegistry.register(model) + + do { + try ModelRegistry.register(model) + } catch { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error registering: \(error)") + } ClientParameterRegistry.shared.register(handler) } - - public static func getModel(_ json: [String: Any]) throws -> ClientParameterModelProtocol { - guard let paramType = json.optionalStringForKey("type") else { - throw ModelRegistry.Error.other(message: "parameterType missing") - } - guard let type = ModelRegistry.getType(for: paramType, with: ClientParameterModelProtocol.self) else { - throw ModelRegistry.Error.decoderErrorModelNotMapped() - } - guard let model = try type.decode(jsonDict: json) as? ClientParameterModelProtocol else { - throw ModelRegistry.Error.decoderError - } - return model - } } diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 93407d1..59dc0c7 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -66,6 +66,22 @@ public struct ModelRegistry { return AnyCodingKey(category.codingKey) } + + + public static func getModelFor(json: [String: Any], type: T.Type) throws -> ModelProtocol? { + + guard let categoryKey = ModelRegistry.getCategory(for: type)?.codingKey else { + throw ModelRegistry.Error.other(message: "coding key missing") + } + guard let parameterType = json.optionalStringForKey(categoryKey) else { + throw ModelRegistry.Error.other(message: "type missing") + } + + guard let type = ModelRegistry.getType(for: parameterType, with: type) else { + throw ModelRegistry.Error.decoderErrorModelNotMapped() + } + return try type.decode(jsonDict: json) + } } extension KeyedDecodingContainer where Key: CodingKey { diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 2eb640e8fa631b505e41c128e159ffece2de522e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 16:32:36 -0500 Subject: [PATCH 024/150] review changes --- .../ActionHandler+ClientParameters.swift | 4 +- .../ActionHandling/MVMCoreActionHandler.m | 12 +++++- .../ClientParameterProtocol.swift | 14 ------ .../ClientParameterRegistry.swift | 43 +++++++------------ MVMCore/MVMCore/Singletons/MVMCoreObject.h | 3 ++ MVMCore/MVMCore/Singletons/MVMCoreObject.m | 2 + 6 files changed, 33 insertions(+), 45 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index bbd951a..360546d 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -10,7 +10,7 @@ import Foundation public extension MVMCoreActionHandler { - @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { + @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) throws { guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { completionHandler(actionMap) @@ -29,7 +29,7 @@ public extension MVMCoreActionHandler { } } - ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in + try ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { stopLoadingOverlay() completionHandler(actionMap) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 90374e5..837cadf 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -449,10 +449,18 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)preprocessRequest:(nullable NSDictionary *)actionInformation actionBlock:(nullable void (^)(NSDictionary*))actionBlock { // Check for client params and fetch the parameters if ([actionInformation dict:@"clientParameters"]) { - [self setClientParameterWith:actionInformation - completionHandler:^(NSDictionary * _Nullable actionDict) { + + NSError *error = nil; + + [self setClientParameterWith:actionInformation error:&error completionHandler:^(NSDictionary * _Nullable actionDict) { actionBlock(actionDict); }]; + + if (error) { + //MVMCoreLoggingHandler.logDebugMessage(withDelegate: "JS function reult: \(String(describing: result))") + MVMCoreLog(@"Error clientParamters %@", error); + actionBlock(actionInformation); + } } else { actionBlock(actionInformation); } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index a954ac4..e2a8129 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -13,17 +13,3 @@ public protocol ClientParameterProtocol { static var name: String { get } func fetchClientParameters(for paramModel: ClientParameterModelProtocol, timingOutIn timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) } - -extension ClientParameterProtocol { - - /// Handle encoding and errors - public func getJSON(with paramModel: ClientParameterModelProtocol?) -> JSONDictionary? { - guard let dataModel = paramModel, - let json = dataModel.toJSON() else { - // JSON parsing failed - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ClientParameterProtocol JSON parsing failed") - return nil - } - return json - } -} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index fe91785..69ea2c4 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -9,9 +9,9 @@ import Foundation -@objcMembers open class ClientParameterRegistry: NSObject { +@objcMembers public class ClientParameterRegistry: NSObject { + - public static let shared = ClientParameterRegistry() private var mapping: [String: ClientParameterProtocol.Type] = [:] public func register(_ handler: T.Type) { @@ -23,22 +23,16 @@ import Foundation return parameterType.init() } - static func getClientParameterModel(_ clientParameters: [String: Any]) -> ClientParameterModel? { - do { - let data = try JSONSerialization.data(withJSONObject: clientParameters) - return try JSONDecoder().decode(ClientParameterModel.self, from: data) - } catch { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error parsing getClientParameterModel: \(error)") - return nil - } + static func getClientParameterModel(_ clientParameters: [String: Any]) throws -> ClientParameterModel? { + let data = try JSONSerialization.data(withJSONObject: clientParameters) + return try JSONDecoder().decode(ClientParameterModel.self, from: data) } - static func injectParameters(with clientParameters: [String: Any], - completionHandler:@escaping ([String: Any]?) -> ()) { + static func injectParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { - let clientParameterRegistry = ClientParameterRegistry.shared + let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry - guard let clientParameterModel = ClientParameterRegistry.getClientParameterModel(clientParameters) else { + guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) return } @@ -48,7 +42,7 @@ import Foundation let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") let group = DispatchGroup() - let defaultErrorString = "Failed to collect." + let defaultErrorString = "failed_to_collect." // Dispatch setup on queue to ensure setup is complete before completion callbacks. parametersWorkQueue.async(group: group, qos: .userInitiated) { @@ -75,25 +69,25 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (clientParam) in + clientParameterRegistry?.injectParameter(parameterModel, before: timeout) { (clientParam) in // Queue the results for merge. parametersWorkQueue.async { if let clientParam = clientParam { - parametersList[parameterModel.type] = clientParam + parametersList.merge(clientParam) { (_, new) in new } + //parametersList[parameterModel.type] = clientParam } group.leave() // Leaving is only done after setup (barriered). } } } - // Callback when all parameters have been merged. group.notify(queue: parametersWorkQueue, work: completionWorkItem); } } func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) { - guard let parammeterHandler = ClientParameterRegistry.shared.createParametersHandler(parameterModel.type) else { + guard let parammeterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } parammeterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) @@ -103,13 +97,8 @@ import Foundation public static func registerParameters() { } /// Register Default Core Bridge Objects - public static func register(handler: T.Type, for model: M.Type) { - - do { - try ModelRegistry.register(model) - } catch { - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error registering: \(error)") - } - ClientParameterRegistry.shared.register(handler) + public static func register(handler: T.Type, for model: M.Type) throws { + try ModelRegistry.register(model) + MVMCoreObject.sharedInstance()?.clientParameterRegistry?.register(handler) } } diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.h b/MVMCore/MVMCore/Singletons/MVMCoreObject.h index 03a8411..023ad63 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.h +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.h @@ -18,6 +18,8 @@ #import #import +@class ClientParameterRegistry; + @interface MVMCoreObject : NSObject @property (nullable, strong, nonatomic) MVMCoreSessionObject *session; @@ -26,6 +28,7 @@ @property (nullable, strong, nonatomic) MVMCoreActionHandler *actionHandler; @property (nullable, strong, nonatomic) MVMCoreSessionTimeHandler *sessionHandler; @property (nullable, strong, nonatomic) MVMCoreLoadHandler *loadHandler; +@property (nullable, strong, nonatomic) ClientParameterRegistry *clientParameterRegistry; // The delegates @property (nullable, strong, nonatomic) id globalLoadDelegate; diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.m b/MVMCore/MVMCore/Singletons/MVMCoreObject.m index 8ad4cb5..fbb0520 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.m +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.m @@ -7,6 +7,7 @@ // #import "MVMCoreObject.h" +#import @implementation MVMCoreObject @@ -27,6 +28,7 @@ self.actionHandler = [[MVMCoreActionHandler alloc] init]; self.loggingDelegate = [[MVMCoreLoggingHandler alloc] init]; self.loadHandler = [[MVMCoreLoadHandler alloc] init]; + self.clientParameterRegistry = [ClientParameterRegistry new]; } @end From 96217a5ad7be39808cac2ab4de8b8bcda01f16d6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 16:35:34 -0500 Subject: [PATCH 025/150] ope --- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 69ea2c4..d75bd79 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -94,7 +94,7 @@ import Foundation } /// Add all registry here. - public static func registerParameters() { } + open static func registerParameters() { } /// Register Default Core Bridge Objects public static func register(handler: T.Type, for model: M.Type) throws { From 2b6bf53cc5c043f83e2b8ab001e98318d91398a6 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 16:44:36 -0500 Subject: [PATCH 026/150] open --- .../Client Parameters/ClientParameterRegistry.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index d75bd79..c3775d8 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -9,16 +9,21 @@ import Foundation -@objcMembers public class ClientParameterRegistry: NSObject { +@objcMembers open class ClientParameterRegistry: NSObject { private var mapping: [String: ClientParameterProtocol.Type] = [:] - public func register(_ handler: T.Type) { + public override init() { + super.init() + registerParameters() + } + + open func register(_ handler: T.Type) { mapping[T.name] = handler } - public func createParametersHandler(_ actionType: String) -> ClientParameterProtocol? { + open func createParametersHandler(_ actionType: String) -> ClientParameterProtocol? { guard let parameterType = mapping[actionType] else { return nil } return parameterType.init() } @@ -94,7 +99,7 @@ import Foundation } /// Add all registry here. - open static func registerParameters() { } + open func registerParameters() { } /// Register Default Core Bridge Objects public static func register(handler: T.Type, for model: M.Type) throws { From 485b16528919125b5a5e949b8b2e4a8dd910f1ff Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 16:47:41 -0500 Subject: [PATCH 027/150] fix error --- MVMCore/MVMCore/Session/MVMCoreSessionObject.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m index 8650972..7134c59 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m @@ -17,7 +17,6 @@ if (self = [super init]) { self.session = [self createNSURLSession]; [ModelMapping registerObjects]; - [ClientParameterRegistry registerParameters]; } return self; } From 49811999f18a572018c6058988212d10578539fc Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 17:04:39 -0500 Subject: [PATCH 028/150] fixes --- .../Client Parameters/ClientParameterRegistry.swift | 7 +++---- MVMCore/MVMCore/Singletons/MVMCoreObject.m | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index c3775d8..a9c3dc2 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -35,9 +35,8 @@ import Foundation static func injectParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { - let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry - - guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { + guard let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry, + let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) return } @@ -74,7 +73,7 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry?.injectParameter(parameterModel, before: timeout) { (clientParam) in + clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (clientParam) in // Queue the results for merge. parametersWorkQueue.async { if let clientParam = clientParam { diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.m b/MVMCore/MVMCore/Singletons/MVMCoreObject.m index fbb0520..6b60d65 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.m +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.m @@ -28,7 +28,7 @@ self.actionHandler = [[MVMCoreActionHandler alloc] init]; self.loggingDelegate = [[MVMCoreLoggingHandler alloc] init]; self.loadHandler = [[MVMCoreLoadHandler alloc] init]; - self.clientParameterRegistry = [ClientParameterRegistry new]; + self.clientParameterRegistry = [[ClientParameterRegistry alloc] init]; } @end From 3344277e357c4f2acfb83263791c954c74919fde Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 20:59:31 -0500 Subject: [PATCH 029/150] cleanup --- .../Client Parameters/ClientParameterRegistry.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index a9c3dc2..3119f5a 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -11,9 +11,9 @@ import Foundation @objcMembers open class ClientParameterRegistry: NSObject { - private var mapping: [String: ClientParameterProtocol.Type] = [:] + public override init() { super.init() registerParameters() @@ -78,7 +78,6 @@ import Foundation parametersWorkQueue.async { if let clientParam = clientParam { parametersList.merge(clientParam) { (_, new) in new } - //parametersList[parameterModel.type] = clientParam } group.leave() // Leaving is only done after setup (barriered). } @@ -100,7 +99,13 @@ import Foundation /// Add all registry here. open func registerParameters() { } - /// Register Default Core Bridge Objects + /// Register Default Core Client Paramter Objects + public func register(handler: T.Type, for model: M.Type) throws { + try ModelRegistry.register(model) + register(handler) + } + + /// Register Default Core Client Paramter Objects public static func register(handler: T.Type, for model: M.Type) throws { try ModelRegistry.register(model) MVMCoreObject.sharedInstance()?.clientParameterRegistry?.register(handler) From 13573eea7f603042c34f0b4a1327f795b31cb5aa Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 15 Jan 2021 21:59:41 -0500 Subject: [PATCH 030/150] map --- .../ActionHandler+ClientParameters.swift | 31 ++++++++++++------- .../ActionHandling/MVMCoreActionHandler.m | 28 +++-------------- .../ClientParameterProtocol.swift | 2 +- .../ClientParameterRegistry.swift | 8 ++--- 4 files changed, 28 insertions(+), 41 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 360546d..2c607b9 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -10,7 +10,7 @@ import Foundation public extension MVMCoreActionHandler { - @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) throws { + @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { completionHandler(actionMap) @@ -29,20 +29,27 @@ public extension MVMCoreActionHandler { } } - try ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in - guard let clientParams = clientParams else { + do { + try ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in + guard let clientParams = clientParams else { + stopLoadingOverlay() + completionHandler(actionMap) + return + } + + var extraParams: [String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] + extraParams.merge(clientParams) { (_, new) in new } + var actionMapM = actionMap + actionMapM?[KeyExtraParameters] = extraParams + stopLoadingOverlay() - completionHandler(actionMap) - return + completionHandler(actionMapM) } - - var extraParams: [String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] - extraParams.merge(clientParams) { (_, new) in new } - var actionMapM = actionMap - actionMapM?[KeyExtraParameters] = extraParams - + } catch { stopLoadingOverlay() - completionHandler(actionMapM) + completionHandler(actionMap) + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error clientParamters: \(error)") } + } } diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 837cadf..9362dd6 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -128,7 +128,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - [self preprocessRequest:actionInformation actionBlock:performAction]; + [self setClientParameterWith:actionInformation completionHandler:performAction]; } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -293,7 +293,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; - [self preprocessRequest:actionInformation actionBlock:performAction]; + [self setClientParameterWith:actionInformation completionHandler:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -443,27 +443,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - [self preprocessRequest:actionInformation actionBlock:performAction]; -} - -- (void)preprocessRequest:(nullable NSDictionary *)actionInformation actionBlock:(nullable void (^)(NSDictionary*))actionBlock { - // Check for client params and fetch the parameters - if ([actionInformation dict:@"clientParameters"]) { - - NSError *error = nil; - - [self setClientParameterWith:actionInformation error:&error completionHandler:^(NSDictionary * _Nullable actionDict) { - actionBlock(actionDict); - }]; - - if (error) { - //MVMCoreLoggingHandler.logDebugMessage(withDelegate: "JS function reult: \(String(describing: result))") - MVMCoreLog(@"Error clientParamters %@", error); - actionBlock(actionInformation); - } - } else { - actionBlock(actionInformation); - } + [self setClientParameterWith:actionInformation completionHandler:performAction]; } - (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { @@ -582,7 +562,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; }; - [self preprocessRequest:actionInformation actionBlock:performAction]; + [self setClientParameterWith:actionInformation completionHandler:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index e2a8129..2c689ec 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,5 +11,5 @@ import Foundation public protocol ClientParameterProtocol { init() static var name: String { get } - func fetchClientParameters(for paramModel: ClientParameterModelProtocol, timingOutIn timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) + func fetchClientParameters(for paramModel: ClientParameterModelProtocol, timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 3119f5a..a5e527a 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -73,11 +73,11 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (clientParam) in + clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (recevedParameter) in // Queue the results for merge. parametersWorkQueue.async { - if let clientParam = clientParam { - parametersList.merge(clientParam) { (_, new) in new } + if let recevedParameter = recevedParameter { + parametersList[parameterModel.type] = recevedParameter } group.leave() // Leaving is only done after setup (barriered). } @@ -89,7 +89,7 @@ import Foundation } } - func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping ([String: Any]?) -> ()) { + func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { guard let parammeterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } From a5e557ef58d42f52fd7ce3bc698c2cd17a4b3603 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 12:24:33 -0500 Subject: [PATCH 031/150] comments --- .../MVMCore/ActionHandling/ActionHandler+ClientParameters.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 2c607b9..5f9cb0a 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -10,6 +10,7 @@ import Foundation public extension MVMCoreActionHandler { + /// Iterates throw the clientParameters list. Gets values from the individul handlers and attaches the paramters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { From cc1a53e21bccbc4f125f781038b358d8a618dfe2 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 12:26:51 -0500 Subject: [PATCH 032/150] typo: receivedParameter --- .../Client Parameters/ClientParameterRegistry.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index a5e527a..03f1f28 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -73,11 +73,11 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (recevedParameter) in + clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { - if let recevedParameter = recevedParameter { - parametersList[parameterModel.type] = recevedParameter + if let receivedParameter = receivedParameter { + parametersList[parameterModel.type] = receivedParameter } group.leave() // Leaving is only done after setup (barriered). } From ef0e5dee1c481932c625369a047cd5d6f7178a33 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 16:25:56 -0500 Subject: [PATCH 033/150] typo --- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 03f1f28..eff2175 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -90,7 +90,7 @@ import Foundation } func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { - guard let parammeterHandler = createParametersHandler(parameterModel.type) else { + guard let parameterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } parammeterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) From 09cf4db857697089f44154bd75a53f49af6c4e95 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 16:30:35 -0500 Subject: [PATCH 034/150] parameterHandler --- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index eff2175..273c6a1 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -93,7 +93,7 @@ import Foundation guard let parameterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } - parammeterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) + parameterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) } /// Add all registry here. From 0091c419d101c1a2c6f0f53fe0e71137c66e7e17 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 16:42:30 -0500 Subject: [PATCH 035/150] code review --- .../ActionHandling/ActionHandler+ClientParameters.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 5f9cb0a..6378cea 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -10,7 +10,7 @@ import Foundation public extension MVMCoreActionHandler { - /// Iterates throw the clientParameters list. Gets values from the individul handlers and attaches the paramters to extraParameters. + /// Iterates threw the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { @@ -38,7 +38,7 @@ public extension MVMCoreActionHandler { return } - var extraParams: [String : Any] = actionMap?.optionalDictionaryForKey(KeyExtraParameters) ?? [:] + var extraParams: [String : Any] = actionMap?.dictionaryForKey(KeyExtraParameters) extraParams.merge(clientParams) { (_, new) in new } var actionMapM = actionMap actionMapM?[KeyExtraParameters] = extraParams From d52b05d0ac1a7806f6417ff9c6c95b926a4cc6d9 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 16:46:39 -0500 Subject: [PATCH 036/150] optionals cleanup --- .../ActionHandler+ClientParameters.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 6378cea..dd0471a 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -13,12 +13,12 @@ public extension MVMCoreActionHandler { /// Iterates threw the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { - guard let clientParameters = actionMap?.optionalDictionaryForKey("clientParameters") else { - completionHandler(actionMap) + guard let actionMap = actionMap, let clientParameters = actionMap.optionalDictionaryForKey("clientParameters") else { + completionHandler(nil) return } - let isBackgroudRequest = actionMap?.boolForKey("background") ?? false + let isBackgroudRequest = actionMap.boolForKey("background") if !isBackgroudRequest { MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() @@ -38,10 +38,10 @@ public extension MVMCoreActionHandler { return } - var extraParams: [String : Any] = actionMap?.dictionaryForKey(KeyExtraParameters) + var extraParams: [String : Any] = actionMap.dictionaryForKey(KeyExtraParameters) extraParams.merge(clientParams) { (_, new) in new } var actionMapM = actionMap - actionMapM?[KeyExtraParameters] = extraParams + actionMapM[KeyExtraParameters] = extraParams stopLoadingOverlay() completionHandler(actionMapM) From 8a9b94bdb0a445ce618af3d3ddaea7928de921a0 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 17:52:16 -0500 Subject: [PATCH 037/150] remove hardcode flag --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 34c4bd18eeb05515a495385cb4c0425364e0b1e0 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 19 Jan 2021 18:25:35 -0500 Subject: [PATCH 038/150] refactor --- .../ActionHandler+ClientParameters.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index dd0471a..928c45d 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -13,12 +13,12 @@ public extension MVMCoreActionHandler { /// Iterates threw the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { - guard let actionMap = actionMap, let clientParameters = actionMap.optionalDictionaryForKey("clientParameters") else { - completionHandler(nil) + guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey("clientParameters") else { + completionHandler(actionMap) return } - let isBackgroudRequest = actionMap.boolForKey("background") + let isBackgroudRequest = actionMapWithClientParameters.boolForKey("background") if !isBackgroudRequest { MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() @@ -34,13 +34,13 @@ public extension MVMCoreActionHandler { try ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { stopLoadingOverlay() - completionHandler(actionMap) + completionHandler(actionMapWithClientParameters) return } - var extraParams: [String : Any] = actionMap.dictionaryForKey(KeyExtraParameters) + var extraParams: [String : Any] = actionMapWithClientParameters.dictionaryForKey(KeyExtraParameters) extraParams.merge(clientParams) { (_, new) in new } - var actionMapM = actionMap + var actionMapM = actionMapWithClientParameters actionMapM[KeyExtraParameters] = extraParams stopLoadingOverlay() @@ -48,7 +48,7 @@ public extension MVMCoreActionHandler { } } catch { stopLoadingOverlay() - completionHandler(actionMap) + completionHandler(actionMapWithClientParameters) MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error clientParamters: \(error)") } From f2855f317bc37b4ae4270abe6fcdf25e9b6afe03 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 20 Jan 2021 10:24:00 -0500 Subject: [PATCH 039/150] code review --- .../ActionHandler+ClientParameters.swift | 4 ++-- .../ClientParameterModel.swift | 2 +- .../ClientParameterRegistry.swift | 20 ++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 928c45d..85fd4bb 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -10,7 +10,7 @@ import Foundation public extension MVMCoreActionHandler { - /// Iterates threw the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. + /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey("clientParameters") else { @@ -31,7 +31,7 @@ public extension MVMCoreActionHandler { } do { - try ClientParameterRegistry.injectParameters(with: clientParameters) { (clientParams) in + try ClientParameterRegistry.getParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { stopLoadingOverlay() completionHandler(actionMapWithClientParameters) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift index 8686d71..37940d7 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModel.swift @@ -25,7 +25,7 @@ public class ClientParameterModel: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(timeout, forKey: .timeout) + try container.encodeIfPresent(timeout, forKey: .timeout) try container.encodeModels(list, forKey: .list) } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 273c6a1..9c4200b 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -33,7 +33,21 @@ import Foundation return try JSONDecoder().decode(ClientParameterModel.self, from: data) } - static func injectParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { + /// Sample clientParameters + ///{ + /// "timeout": 30, + /// "list": [ + /// { + /// "type": "currentLocation", + /// "inputParameters": { + /// "accuracy": 10, + /// "timeThreshold": 600 + /// } + /// } + /// ] + ///} + /// completionHandler can return flat dictinary or a map. It depends on the paramters handler + static func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { guard let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry, let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { @@ -73,7 +87,7 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.injectParameter(parameterModel, before: timeout) { (receivedParameter) in + clientParameterRegistry.getParameterFromHandler(parameterModel, before: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { if let receivedParameter = receivedParameter { @@ -89,7 +103,7 @@ import Foundation } } - func injectParameter( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { + func getParameterFromHandler( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { guard let parameterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } From 35962ff9664ceceaf54ba1ce64de5a33256c3091 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 20 Jan 2021 10:52:42 -0500 Subject: [PATCH 040/150] remove static --- .../MVMCore/ActionHandling/ActionHandler+ClientParameters.swift | 2 +- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 2 +- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 85fd4bb..9d6deab 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -31,7 +31,7 @@ public extension MVMCoreActionHandler { } do { - try ClientParameterRegistry.getParameters(with: clientParameters) { (clientParams) in + try ClientParameterRegistry().getParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { stopLoadingOverlay() completionHandler(actionMapWithClientParameters) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 9c4200b..23f5ca5 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -47,7 +47,7 @@ import Foundation /// ] ///} /// completionHandler can return flat dictinary or a map. It depends on the paramters handler - static func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { + func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { guard let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry, let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 5fda7b15b5222c1b77f14250d5542fa7f376d159 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 20 Jan 2021 10:53:25 -0500 Subject: [PATCH 041/150] remove hardcode --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From dcd2dc4fd8e696c16ce64ca0d939a297bd909366 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 20 Jan 2021 11:52:58 -0500 Subject: [PATCH 042/150] code review --- .../ActionHandling/ActionHandler+ClientParameters.swift | 2 +- .../Client Parameters/ClientParameterRegistry.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index 9d6deab..a2c3841 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -31,7 +31,7 @@ public extension MVMCoreActionHandler { } do { - try ClientParameterRegistry().getParameters(with: clientParameters) { (clientParams) in + try MVMCoreObject.sharedInstance()?.clientParameterRegistry?.getParameters(with: clientParameters) { (clientParams) in guard let clientParams = clientParams else { stopLoadingOverlay() completionHandler(actionMapWithClientParameters) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 23f5ca5..ba698f4 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -49,8 +49,7 @@ import Foundation /// completionHandler can return flat dictinary or a map. It depends on the paramters handler func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { - guard let clientParameterRegistry = MVMCoreObject.sharedInstance()?.clientParameterRegistry, - let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { + guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) return } @@ -63,7 +62,8 @@ import Foundation let defaultErrorString = "failed_to_collect." // Dispatch setup on queue to ensure setup is complete before completion callbacks. - parametersWorkQueue.async(group: group, qos: .userInitiated) { + parametersWorkQueue.async(group: group, qos: .userInitiated) { [weak self] in + guard let self = self else { return } // Setup completion handlers. Barriered to ensure one happens after the other. var complete = false let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { @@ -87,7 +87,7 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - clientParameterRegistry.getParameterFromHandler(parameterModel, before: timeout) { (receivedParameter) in + self.getParameterFromHandler(parameterModel, before: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { if let receivedParameter = receivedParameter { From 8ed40b8a036e3043875666aab8e9f731a9ca6bb7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 20 Jan 2021 12:18:11 -0500 Subject: [PATCH 043/150] removed unused code --- MVMCore/MVMCore/Models/Model/ModelRegistry.swift | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 59dc0c7..93407d1 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -66,22 +66,6 @@ public struct ModelRegistry { return AnyCodingKey(category.codingKey) } - - - public static func getModelFor(json: [String: Any], type: T.Type) throws -> ModelProtocol? { - - guard let categoryKey = ModelRegistry.getCategory(for: type)?.codingKey else { - throw ModelRegistry.Error.other(message: "coding key missing") - } - guard let parameterType = json.optionalStringForKey(categoryKey) else { - throw ModelRegistry.Error.other(message: "type missing") - } - - guard let type = ModelRegistry.getType(for: parameterType, with: type) else { - throw ModelRegistry.Error.decoderErrorModelNotMapped() - } - return try type.decode(jsonDict: json) - } } extension KeyedDecodingContainer where Key: CodingKey { From 78749afddc7c26123d3cdee3d77edb889d614a07 Mon Sep 17 00:00:00 2001 From: "Chintakrinda, Arun Kumar (Arun)" Date: Thu, 21 Jan 2021 18:38:19 +0530 Subject: [PATCH 044/150] Added missing key hideUrl --- MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift index 03a1e95..14006a1 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenUrlModel.swift @@ -30,6 +30,7 @@ public var dontShowProgress: Bool? public var headerParameters: JSONValueDictionary? public var enableNativeScroll: Bool? + public var hideUrl: Bool? //-------------------------------------------------- // MARK: - Initialzier From b6e1e84b52a99ad7261063001cd467b902944517 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 10:49:43 -0500 Subject: [PATCH 045/150] CXTDT-149032 --- .../ActionHandling/MVMCoreActionHandler.m | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 9362dd6..5095fc8 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -128,7 +128,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - [self setClientParameterWith:actionInformation completionHandler:performAction]; + // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + if ([actionInformation dict:@"clientParameters"]) { + [self setClientParameterWith:actionInformation completionHandler:performAction]; + } else { + performAction(actionInformation); + } } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -293,7 +298,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; - [self setClientParameterWith:actionInformation completionHandler:performAction]; + // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + if ([actionInformation dict:@"clientParameters"]) { + [self setClientParameterWith:actionInformation completionHandler:performAction]; + } else { + performAction(actionInformation); + } } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -443,7 +453,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - [self setClientParameterWith:actionInformation completionHandler:performAction]; + // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + if ([actionInformation dict:@"clientParameters"]) { + [self setClientParameterWith:actionInformation completionHandler:performAction]; + } else { + performAction(actionInformation); + } } - (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { @@ -562,7 +577,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; }; - [self setClientParameterWith:actionInformation completionHandler:performAction]; + // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + if ([actionInformation dict:@"clientParameters"]) { + [self setClientParameterWith:actionInformation completionHandler:performAction]; + } else { + performAction(actionInformation); + } } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { From 93a590fedf059c1a256752ac014ca61b3a9960fb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 11:00:37 -0500 Subject: [PATCH 046/150] KeyClientParameters --- .../ActionHandling/ActionHandler+ClientParameters.swift | 2 +- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 8 ++++---- MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h | 2 ++ MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift index a2c3841..abeec70 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift @@ -13,7 +13,7 @@ public extension MVMCoreActionHandler { /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { - guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey("clientParameters") else { + guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey(KeyClientParameters) else { completionHandler(actionMap) return } diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 5095fc8..125e1d5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -129,7 +129,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }; // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map - if ([actionInformation dict:@"clientParameters"]) { + if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { performAction(actionInformation); @@ -299,7 +299,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }; // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map - if ([actionInformation dict:@"clientParameters"]) { + if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { performAction(actionInformation); @@ -454,7 +454,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }; // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map - if ([actionInformation dict:@"clientParameters"]) { + if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { performAction(actionInformation); @@ -578,7 +578,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }; // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map - if ([actionInformation dict:@"clientParameters"]) { + if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { performAction(actionInformation); diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index f3d84ac..220b180 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -51,6 +51,8 @@ extern NSString * const KeyContextRoot; extern NSString * const KeyType; extern NSString * const KeyMVMRC; +extern NSString * const KeyClientParameters; + #pragma mark - JSON Values // Server driven response type diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 71cccac..2127e2e 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -51,6 +51,8 @@ NSString * const KeyContextRoot = @"appContext"; NSString * const KeyType = @"type"; NSString * const KeyMVMRC = @"LaunchMVMRC"; +NSString * const KeyClientParameters = @"clientParameters"; + #pragma mark - JSON Values // Server driven response type From 5d92df53472b5edddf73ea402d96e19340eefcaf Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 11:13:17 -0500 Subject: [PATCH 047/150] typo --- .../ActionHandling/MVMCoreActionHandler.m | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 125e1d5..d069404 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -128,7 +128,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + /* + BAU dictionary comparsion breaks if client parameters sets the dictionary. + For now we will set client parameters only when its sent in the action map. + We can move the code to Objective-C if required. + */ if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { @@ -298,7 +302,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; - // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + /* + BAU dictionary comparsion breaks if client parameters sets the dictionary. + For now we will set client parameters only when its sent in the action map. + We can move the code to Objective-C if required. + */ if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { @@ -453,7 +461,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + /* + BAU dictionary comparsion breaks if client parameters sets the dictionary. + For now we will set client parameters only when its sent in the action map. + We can move the code to Objective-C if required. + */ if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { @@ -577,7 +589,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; }; - // BAU dictionary comparsion breaks if client paramters sets the dictionarr. For now we will set client paramters only when its sent in the action map + /* + BAU dictionary comparsion breaks if client parameters sets the dictionary. + For now we will set client parameters only when its sent in the action map. + We can move the code to Objective-C if required. + */ if ([actionInformation dict:KeyClientParameters]) { [self setClientParameterWith:actionInformation completionHandler:performAction]; } else { From 45b84ae2e09eb1e015d5745d0bdae8aca70045cb Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:00:29 -0500 Subject: [PATCH 048/150] redone in objecitve c --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 - .../ActionHandler+ClientParameters.swift | 56 ----------- .../ActionHandling/MVMCoreActionHandler.m | 93 +++++++++++-------- .../ClientParameterRegistry.swift | 2 +- .../MFHardCodedServerResponse.h | 2 +- 5 files changed, 56 insertions(+), 101 deletions(-) delete mode 100644 MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index aa096b4..b06322b 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */; }; 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */; }; 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */; }; - 016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */; }; 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; }; @@ -154,7 +153,6 @@ 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModel.swift; sourceTree = ""; }; 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = ""; }; 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterProtocol.swift; sourceTree = ""; }; - 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActionHandler+ClientParameters.swift"; sourceTree = ""; }; 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; 01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = ""; }; @@ -585,7 +583,6 @@ AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */, AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */, AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */, - 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */, ); path = ActionHandling; sourceTree = ""; @@ -810,7 +807,6 @@ buildActionMask = 2147483647; files = ( AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */, - 016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */, 946EE1A7237B5B1C0036751F /* ModelRegistry.swift in Sources */, AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */, AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift b/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift deleted file mode 100644 index abeec70..0000000 --- a/MVMCore/MVMCore/ActionHandling/ActionHandler+ClientParameters.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// ActionHandler+ClientParameters.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 12/30/20. -// Copyright © 2020 myverizon. All rights reserved. -// - -import Foundation - -public extension MVMCoreActionHandler { - - /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. - @objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) { - - guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey(KeyClientParameters) else { - completionHandler(actionMap) - return - } - - let isBackgroudRequest = actionMapWithClientParameters.boolForKey("background") - - if !isBackgroudRequest { - MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() - } - - let stopLoadingOverlay = {() in - if !isBackgroudRequest { - MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true) - } - } - - do { - try MVMCoreObject.sharedInstance()?.clientParameterRegistry?.getParameters(with: clientParameters) { (clientParams) in - guard let clientParams = clientParams else { - stopLoadingOverlay() - completionHandler(actionMapWithClientParameters) - return - } - - var extraParams: [String : Any] = actionMapWithClientParameters.dictionaryForKey(KeyExtraParameters) - extraParams.merge(clientParams) { (_, new) in new } - var actionMapM = actionMapWithClientParameters - actionMapM[KeyExtraParameters] = extraParams - - stopLoadingOverlay() - completionHandler(actionMapM) - } - } catch { - stopLoadingOverlay() - completionHandler(actionMapWithClientParameters) - MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error clientParamters: \(error)") - } - - } -} diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index d069404..3b2d704 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -26,6 +26,7 @@ #import "MVMCorePresentationDelegateProtocol.h" #import #import +#import "MVMCoreLoadingOverlayHandler.h" NSString * const KeyActionType = @"actionType"; NSString * const KeyActionTypeLinkAway = @"openURL"; @@ -128,16 +129,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - /* - BAU dictionary comparsion breaks if client parameters sets the dictionary. - For now we will set client parameters only when its sent in the action map. - We can move the code to Objective-C if required. - */ - if ([actionInformation dict:KeyClientParameters]) { - [self setClientParameterWith:actionInformation completionHandler:performAction]; - } else { - performAction(actionInformation); - } + [self setClientParameter:actionInformation completionHandler:performAction]; } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -302,16 +294,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; - /* - BAU dictionary comparsion breaks if client parameters sets the dictionary. - For now we will set client parameters only when its sent in the action map. - We can move the code to Objective-C if required. - */ - if ([actionInformation dict:KeyClientParameters]) { - [self setClientParameterWith:actionInformation completionHandler:performAction]; - } else { - performAction(actionInformation); - } + [self setClientParameter:actionInformation completionHandler:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -461,16 +444,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - /* - BAU dictionary comparsion breaks if client parameters sets the dictionary. - For now we will set client parameters only when its sent in the action map. - We can move the code to Objective-C if required. - */ - if ([actionInformation dict:KeyClientParameters]) { - [self setClientParameterWith:actionInformation completionHandler:performAction]; - } else { - performAction(actionInformation); - } + [self setClientParameter:actionInformation completionHandler:performAction]; } - (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { @@ -589,15 +563,56 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate]; }; - /* - BAU dictionary comparsion breaks if client parameters sets the dictionary. - For now we will set client parameters only when its sent in the action map. - We can move the code to Objective-C if required. - */ - if ([actionInformation dict:KeyClientParameters]) { - [self setClientParameterWith:actionInformation completionHandler:performAction]; - } else { - performAction(actionInformation); + [self setClientParameter:actionInformation completionHandler:performAction]; +} + +/// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. +- (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler { + + NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; + if (!clientParametersMap) { + completionHandler(actionInformation); + return; + } + + BOOL isBackgroudRequest = [actionInformation boolForKey:@"background"]; + + if (!isBackgroudRequest) { + [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading]; + } + + void (^stopLoadingOverlay)(void) = ^(void) { + if (!isBackgroudRequest) { + [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:true]; + } + }; + + NSError *error = nil; + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; + [[[MVMCoreObject sharedInstance] clientParameterRegistry] getParametersWith:clientParametersMap + error:&error + completionHandler:^(NSDictionary * _Nullable clientParameters) { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; + if (clientParameters) { + NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; + NSMutableDictionary *extraParameters = [clientParameters mutableCopy]; + [extraParameters addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; + actionWithClientParameters[KeyExtraParameters] = extraParameters; + + stopLoadingOverlay(); + completionHandler(actionWithClientParameters); + } else { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client paramnters"]; + stopLoadingOverlay(); + completionHandler(actionInformation); + } + }]; + + if (error) { + stopLoadingOverlay(); + completionHandler(actionInformation); + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Error clientparameters"]; + [MVMCoreLoggingHandler logDebugMessageWithDelegate:error.debugDescription]; } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index ba698f4..1a4160d 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -47,7 +47,7 @@ import Foundation /// ] ///} /// completionHandler can return flat dictinary or a map. It depends on the paramters handler - func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { + open func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 4e1e563284642f7345eadebe62bbbd5fe7a9fa16 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:01:40 -0500 Subject: [PATCH 049/150] remove hardcode --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From b00e9c48950ef48b816a5dc99e7d8ae27a5da8ee Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:27:25 -0500 Subject: [PATCH 050/150] code review --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h | 2 ++ MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index c677e53..374b968 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -158,4 +158,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // By default, throws an error, calling defaultHandleActionError. + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; +// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. +- (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler; @end diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 3b2d704..a717595 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -566,7 +566,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; [self setClientParameter:actionInformation completionHandler:performAction]; } -/// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. - (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler { NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; @@ -611,8 +610,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if (error) { stopLoadingOverlay(); completionHandler(actionInformation); - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Error clientparameters"]; - [MVMCoreLoggingHandler logDebugMessageWithDelegate:error.debugDescription]; + [MVMCoreLoggingHandler addErrorToLog:error]; } } From aa3390e501aa5074e98590037df34b865b27c8e3 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:30:56 -0500 Subject: [PATCH 051/150] typo --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index a717595..d955860 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -601,7 +601,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; stopLoadingOverlay(); completionHandler(actionWithClientParameters); } else { - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client paramnters"]; + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; stopLoadingOverlay(); completionHandler(actionInformation); } From c3fb8aee96023e72d2359f99666df60d2516e0de Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:38:56 -0500 Subject: [PATCH 052/150] MVMCoreErrorObject --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index d955860..20e0145 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -610,7 +610,8 @@ NSString * const KeyActionTypeOpen = @"openPage"; if (error) { stopLoadingOverlay(); completionHandler(actionInformation); - [MVMCoreLoggingHandler addErrorToLog:error]; + MVMCoreErrorObject* errorObject = [MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler"]; + [MVMCoreLoggingHandler addErrorToLog:errorObject]; } } From b9463930f8d8dec22dcb3825077799c7487318c0 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 21 Jan 2021 13:45:24 -0500 Subject: [PATCH 053/150] code review --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 20e0145..fa98ee6 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -610,8 +610,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if (error) { stopLoadingOverlay(); completionHandler(actionInformation); - MVMCoreErrorObject* errorObject = [MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler"]; - [MVMCoreLoggingHandler addErrorToLog:errorObject]; + [MVMCoreLoggingHandler addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler->setClientParameter"]]; } } From 02cbfb702c81882fca1f2a579317207823803ecd Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 22 Jan 2021 10:03:28 -0500 Subject: [PATCH 054/150] reset --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 9c0e4c89d3ed0e3e7b2d770f8b48310b17333028 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 22 Jan 2021 17:09:01 -0500 Subject: [PATCH 055/150] actions action and minor cleanup --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 12 + ...CoreActionDelegateProtocol+Extension.swift | 16 + .../MVMCoreActionHandler+Extension.swift | 39 ++ .../ActionHandling/MVMCoreActionHandler.h | 65 +--- .../ActionHandling/MVMCoreActionHandler.m | 342 +++--------------- .../ActionType/ActionActionsModel.swift | 67 ++++ 6 files changed, 201 insertions(+), 340 deletions(-) create mode 100644 MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift create mode 100644 MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift create mode 100644 MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index fc17f77..e8ce53e 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -135,6 +135,9 @@ AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFFCFA631FCCC0D600FD0730 /* MVMCoreLoadingOverlayHandler.m */; }; AFFCFA681FCCC0D700FD0730 /* MVMCoreLoadingViewControllerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFFCFA641FCCC0D600FD0730 /* MVMCoreLoadingViewControllerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */; }; + D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073B625BB45C4001C7246 /* ActionActionsModel.swift */; }; + D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */; }; + D27073D125BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */; }; D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */; }; D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB72240342D00C46919 /* NSNumber+Extension.swift */; }; D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */; }; @@ -266,6 +269,9 @@ AFFCFA631FCCC0D600FD0730 /* MVMCoreLoadingOverlayHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreLoadingOverlayHandler.m; sourceTree = ""; }; AFFCFA641FCCC0D600FD0730 /* MVMCoreLoadingViewControllerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadingViewControllerProtocol.h; sourceTree = ""; }; BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNoopModel.swift; sourceTree = ""; }; + D27073B625BB45C4001C7246 /* ActionActionsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionActionsModel.swift; sourceTree = ""; }; + D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionHandler+Extension.swift"; sourceTree = ""; }; + D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionDelegateProtocol+Extension.swift"; sourceTree = ""; }; D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreGetterUtility+Extension.swift"; sourceTree = ""; }; D282AAB72240342D00C46919 /* NSNumber+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSNumber+Extension.swift"; sourceTree = ""; }; D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clamping.swift; sourceTree = ""; }; @@ -416,6 +422,7 @@ 94C014D424211AF0005811A9 /* ActionCancelModel.swift */, 94C014D824212360005811A9 /* ActionSettingModel.swift */, BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, + D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, ); path = ActionType; sourceTree = ""; @@ -558,8 +565,10 @@ isa = PBXGroup; children = ( AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */, + D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */, AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */, AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */, + D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */, ); path = ActionHandling; sourceTree = ""; @@ -813,6 +822,7 @@ D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */, 94C014D3242119E6005811A9 /* ActionPreviousSubmitModel.swift in Sources */, 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, + D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, @@ -826,6 +836,7 @@ AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */, 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */, AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */, + D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift in Sources */, 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */, 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */, AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */, @@ -839,6 +850,7 @@ AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */, AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */, 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */, + D27073D125BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift in Sources */, AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */, AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */, 946EE1B4237B619D0036751F /* Encoder.swift in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift new file mode 100644 index 0000000..5a53a0b --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift @@ -0,0 +1,16 @@ +// +// MVMCoreActionDelegateProtocolExtension.swift +// MVMCore +// +// Created by Scott Pfeil on 1/22/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + +public extension MVMCoreActionDelegateProtocol { + // Handles any action errors. + func handleAction(error: MVMCoreErrorObject, action: ActionModelProtocol, additionalData: [AnyHashable: Any]?) { + MVMCoreActionHandler.shared()?.defaultHandleActionError(error, additionalData: additionalData) + } +} diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift new file mode 100644 index 0000000..1df7687 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift @@ -0,0 +1,39 @@ +// +// MVMCoreActionHandler+Extension.swift +// MVMCore +// +// Created by Scott Pfeil on 1/22/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + +public extension MVMCoreActionHandler { + + /// Converts the action to json for old action handler to handle. + func convertActionToJSON(_ model: ActionModelProtocol, delegateObject: DelegateObject?) -> [AnyHashable: Any]? { + do { + let data = try model.encode() + guard let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [AnyHashable: Any] else { + throw ModelRegistry.Error.decoderError + } + return json + } catch { + let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "")! + delegateObject?.actionDelegate?.handleAction(error: errorObject, action: model, additionalData: model.extraParameters) ?? MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: model.extraParameters) + return nil + } + } + + /// Start action on current thread. + func syncHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { + guard let json = convertActionToJSON(model, delegateObject: delegateObject) else { return } + synchronouslyHandleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + } + + /// Start action on dispatched background thread. + func asyncHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { + guard let json = convertActionToJSON(model, delegateObject: delegateObject) else { return } + handleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + } +} diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index c677e53..26103f4 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -25,9 +25,12 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values - (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Handles actions. Used by server driven user actions.. +// Asynchronously handles action (dispatches and calls below function). Used by server driven user actions.. - (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +// Synchronously handles action. Used by server driven user actions.. +- (void)synchronouslyHandleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + #pragma mark - Actions // by default, returns the original RequestParameter that passed in. Can be overriden for some generic updates to the RequestParameter before handle open page action gets called. - (void)updateRequestParametersBeforeHandleOpenPageAction:(nonnull MVMCoreRequestParameters *)requestParameters callBack:(void (^_Nonnull)(MVMCoreRequestParameters * _Nonnull requestParameters))callback; @@ -59,6 +62,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Goes to settings app - (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +/// Performs multiple actions +- (void)actions:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + // Subclass this to handle other custom actions. Return YES if handled, and NO if not. - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; @@ -101,61 +107,4 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values - (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; -// Handles actions. Used by server driven user actions.. -- (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Logs the action. Currently is not action information driven... depends on delegate. -- (void)logAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Tries to open a page -- (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// restarts the app -- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Goes back -- (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Makes a phone call -- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Makes the previous request, needs the delegate for this -- (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Redirects to another experience -- (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Cancels (like in a popup) -- (void)cancelAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Goes to settings app -- (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Subclass this to handle other custom actions. Return YES if handled, and NO if not. -- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Last chance to handle unknown actions before throwing an error -- (void)unknownAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Handles action errors. -- (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Links away to app or browser -- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Can subclass to add to urls if needed at global level (delegate is also called) -- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Opens the url -- (void)openURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// opens the url in a webview. -- (void)openURLInWebView:(nullable NSURL *)url actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Sends the request to the load handler. -+ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject*)delegate __deprecated; - -// By default, throws an error, calling defaultHandleActionError. -+ (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - @end diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index ee539d0..4c72157 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -44,50 +44,52 @@ NSString * const KeyActionTypeOpen = @"openPage"; } - (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - - // Logs the action. - [self logAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - if ([actionType isEqualToString:KeyActionTypeOpen]) { - [self openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeLinkAway]) { - [self linkAwayAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeRestart]) { - [self restartAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeBack]) { - [self backAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeCall]) { - [self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeShare]) { - [self shareAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { - [self previousSubmitAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { - [self redirectAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeCancel]) { - [self cancelAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeSettings]) { - [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeNoop]){ - } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) { - // not a known action type. - [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + [self synchronouslyHandleAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; }); } +- (void)synchronouslyHandleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + // Logs the action. + [self logAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + if ([actionType isEqualToString:KeyActionTypeOpen]) { + [self openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeLinkAway]) { + [self linkAwayAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeRestart]) { + [self restartAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeBack]) { + [self backAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeCall]) { + [self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeShare]) { + [self shareAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { + [self previousSubmitAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { + [self redirectAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeCancel]) { + [self cancelAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeSettings]) { + [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeNoop]){ + } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) { + // not a known action type. + [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } +} + #pragma mark - Actions - (void)updateRequestParametersBeforeHandleOpenPageAction:(nonnull MVMCoreRequestParameters *)requestParameters callBack:(void (^_Nonnull)(MVMCoreRequestParameters * _Nonnull requestParameters))callback { @@ -241,6 +243,19 @@ NSString * const KeyActionTypeOpen = @"openPage"; [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; } +- (void)actions:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + NSArray *actions = [actionInformation array:@"actions"]; + BOOL concurrent = [actionInformation boolForKey:@"concurrent"]; + for (NSDictionary *action in actions) { + NSString *actionType = [action string:KeyActionType]; + if (concurrent) { + [self handleAction:actionType actionInformation:action additionalData:additionalData delegateObject:delegateObject]; + } else { + [self synchronouslyHandleAction:actionType actionInformation:action additionalData:additionalData delegateObject:delegateObject]; + } + } +} + - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { return NO; } @@ -363,248 +378,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - NSString *action = [dictionary stringForKey:KeyActionType]; - [self handleAction:action actionInformation:dictionary additionalData:additionalData delegate:delegate]; -} - -- (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - - // Logs the action. - [self logAction:actionInformation additionalData:additionalData delegate:delegate]; - - if ([actionType isEqualToString:KeyActionTypeOpen]) { - [self openPageAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeLinkAway]) { - [self linkAwayAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeRestart]) { - [self restartAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeBack]) { - [self backAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeCall]) { - [self callAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { - [self previousSubmitAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { - [self redirectAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeCancel]) { - [self cancelAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeSettings]) { - [self settingsAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegate:delegate]) { - // not a known action type. - [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } - }); -} - -- (void)logAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - if ([delegate respondsToSelector:@selector(logActionWithActionInformation:additionalData:)]) { - [delegate logActionWithActionInformation:actionInformation additionalData:additionalData]; - } else { - [MVMCoreActionHandler defaultLogAction:actionInformation additionalData:additionalData delegate:delegate]; - } -} - -- (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - // Loads the given page type. - NSString *pageType = [actionInformation stringForKey:KeyPageType]; - if (pageType.length > 0) { - MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; - - [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { - if ([delegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { - [delegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; - } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegate:delegate]; - } - }]; - } else { - - // No page type to load, show error. - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeOpen]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } -} - -- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - // Invalidates the session before restarting. - [[MVMCoreSessionTimeHandler sharedSessionHandler] invalidateSession:^(MVMCoreErrorObject * _Nullable error) { - - // Restarts the app (forcing any passed in page types). - if (error.code != NSURLErrorCancelled) { - - if (error) { - - // Error invalidating. - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } else { - - // Restart the application with the page type. - NSString *pageType = [actionInformation string:KeyPageType]; - NSDictionary *parameters = [actionInformation dict:KeyExtraParameters]; - [[MVMCoreSessionObject sharedGlobal] restartSessionWithPageType:pageType parameters:parameters clearAllVariables:YES]; - } - } - }]; -} - -- (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Go back. - if ([delegate respondsToSelector:@selector(handleBackAction:additionalData:)]) { - [delegate handleBackAction:actionInformation additionalData:additionalData]; - } else { - [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; - } -} - -- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Call - NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; - [MVMCoreActionUtility linkAway:[@"tel://" stringByAppendingString:callNumber] appURLString:nil]; -} - -- (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Perform the previous submission. - __weak typeof(self) weakSelf = self; - if ([delegate respondsToSelector:@selector(prepareRequestForPreviousSubmission:additionalData:submit:)]) { - [delegate prepareRequestForPreviousSubmission:actionInformation additionalData:additionalData submit:^(MVMCoreRequestParameters * _Nonnull requestParameters, NSDictionary * _Nullable dataForPage) { - - [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { - // Give the delegate a chance to alter the request parameters - if ([delegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { - [delegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:dataForPage]; - } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegate:delegate]; - } - }]; - }]; - } -} - -- (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Have delegate redirect. - [[MVMCoreSessionObject sharedGlobal] redirectWithInfo:actionInformation]; -} - -- (void)cancelAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - if ([delegate respondsToSelector:@selector(handleCancel:additionalData:)]) { - [delegate handleCancel:actionInformation additionalData:additionalData]; - } -} - -- (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Opens the settings. - [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; -} - -- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - return NO; -} - -- (void)unknownAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - if ([delegate respondsToSelector:@selector(handleUnknownActionType:actionInformation:additionalData:)]) { - [delegate handleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData]; - } else { - [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } -} - -- (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - if (error) { - if ([delegate respondsToSelector:@selector(handleActionError:additionalData:)]) { - [delegate handleActionError:error additionalData:additionalData]; - } else { - [self defaultHandleActionError:error additionalData:additionalData]; - } - } -} - -- (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - // Gets the app url - NSURL *appURL = nil; - NSString *appURLString = [actionInformation string:KeyLinkAwayAppURL]; - if (appURLString.length > 0) { - appURL = [NSURL URLWithString:appURLString]; - } - - // Gets the browser url - NSURL *otherURL = nil; - NSString *otherURLString = [actionInformation string:KeyLinkAwayURL]; - if (otherURLString.length > 0) { - otherURL = [NSURL URLWithString:otherURLString]; - } - - // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [self prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionInformation additionalData:additionalData delegate:delegate]; -} - -- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - void(^openURL)(NSURL *, NSURL *, NSDictionary *, NSDictionary *) = ^(NSURL *appURL, NSURL *URL, NSDictionary *actionInformation, NSDictionary *additionalData) { - [self openURL:url appURL:appURL actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - }; - - // Allow delegate to modify before opening the url. - if ([delegate respondsToSelector:@selector(shouldLinkAwayWithURL:appURL:actionInformation:additionalData:linkAwayBlock:)]) { - [delegate shouldLinkAwayWithURL:url appURL:appURL actionInformation:actionInformation additionalData:additionalData linkAwayBlock:openURL]; - } else { - openURL(appURL,url,actionInformation,additionalData); - } -} - -- (void)openURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - - // First try to open the application. - if (appURL && [[UIApplication sharedApplication] canOpenURL:appURL]) { - [[UIApplication sharedApplication] openURL:appURL options:@{} completionHandler:NULL]; - } else if (url && [[UIApplication sharedApplication] canOpenURL:url]) { - - // Check if we should load in webview - BOOL openInWebview = [actionInformation boolForKey:@"openInWebview"]; - if (openInWebview) { - [self openURLInWebView:url actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } else { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:NULL]; - } - } else { - [MVMCoreDispatchUtility performBlockInBackground:^{ - // Cannot linkaway, show error. - MVMCoreErrorObject *error = error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeLinkAway]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - }]; - } - }]; -} - -- (void)openURLInWebView:(nullable NSURL *)url actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - // Presents standard webview. - SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - //safariViewController.delegate = self; - safariViewController.preferredBarTintColor = [UIColor whiteColor]; - safariViewController.preferredControlTintColor = [UIColor blackColor]; - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; -} - -+ (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate{ - // Currently no default log action but this will eventually be server driven. -} - -+ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject*)delegate { - [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegate:delegate]; -} - -+ (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegate class]),actionType]]; - [[self sharedActionHandler] defaultHandleActionError:error additionalData:additionalData]; + DelegateObject *delegateObject = [[DelegateObject alloc] init]; + delegateObject.actionDelegate = delegate; + delegateObject.presentationDelegate = delegate; + delegateObject.loadDelegate = delegate; + [self handleActionWithDictionary:dictionary additionalData:additionalData delegateObject:delegateObject]; } @end diff --git a/MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift new file mode 100644 index 0000000..0638f3e --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift @@ -0,0 +1,67 @@ +// +// ActionActionsModel.swift +// MVMCore +// +// Created by Scott Pfeil on 1/22/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + +@objcMembers open class ActionActionsModel: ActionModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "actions" + public var actionType: String = ActionActionsModel.identifier + public var actions: [ActionModelProtocol] + public var concurrent = true + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initialzier + //-------------------------------------------------- + + public init(actions: [ActionModelProtocol], extraParameters: JSONValueDictionary? = nil, analyticsData: JSONValueDictionary? = nil) { + self.actions = actions + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case actionType + case actions + case concurrent + case extraParameters + case analyticsData + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + actions = try typeContainer.decodeModels(codingKey: .actions) + if let concurrent = try typeContainer.decodeIfPresent(Bool.self, forKey: .concurrent) { + self.concurrent = concurrent + } + extraParameters = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .extraParameters) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(actionType, forKey: .actionType) + try container.encodeModels(actions, forKey: .actions) + try container.encode(concurrent, forKey: .concurrent) + try container.encodeIfPresent(extraParameters, forKey: .extraParameters) + try container.encodeIfPresent(analyticsData, forKey: .analyticsData) + } +} From 6c81a62e5fdf5587d9a43c038352f3339c0f9277 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Jan 2021 09:31:55 -0500 Subject: [PATCH 056/150] review comments --- ...CoreActionDelegateProtocol+Extension.swift | 2 +- .../MVMCoreActionHandler+Extension.swift | 5 +- .../ActionHandling/MVMCoreActionHandler.h | 52 +++++++++---------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift index 5a53a0b..1308ee5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift @@ -9,7 +9,7 @@ import Foundation public extension MVMCoreActionDelegateProtocol { - // Handles any action errors. + /// Handles any action errors. func handleAction(error: MVMCoreErrorObject, action: ActionModelProtocol, additionalData: [AnyHashable: Any]?) { MVMCoreActionHandler.shared()?.defaultHandleActionError(error, additionalData: additionalData) } diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift index 1df7687..5acdbca 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift @@ -19,8 +19,9 @@ public extension MVMCoreActionHandler { } return json } catch { - let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "")! - delegateObject?.actionDelegate?.handleAction(error: errorObject, action: model, additionalData: model.extraParameters) ?? MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: model.extraParameters) + if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") { + delegateObject?.actionDelegate?.handleAction(error: errorObject, action: model, additionalData: model.extraParameters) ?? MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: model.extraParameters) + } return nil } } diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 26103f4..a7c22dd 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -19,92 +19,92 @@ extern NSString * _Nonnull const KeyActionTypeOpen; @interface MVMCoreActionHandler : NSObject -// Returns the shared action handler +/// Returns the shared action handler + (nullable instancetype)sharedActionHandler; -// Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values +/// Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values - (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Asynchronously handles action (dispatches and calls below function). Used by server driven user actions.. +/// Asynchronously handles action (dispatches and calls below function). Used by server driven user actions.. - (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Synchronously handles action. Used by server driven user actions.. +/// Synchronously handles action. Used by server driven user actions.. - (void)synchronouslyHandleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; #pragma mark - Actions -// by default, returns the original RequestParameter that passed in. Can be overriden for some generic updates to the RequestParameter before handle open page action gets called. +/// by default, returns the original RequestParameter that passed in. Can be overriden for some generic updates to the RequestParameter before handle open page action gets called. - (void)updateRequestParametersBeforeHandleOpenPageAction:(nonnull MVMCoreRequestParameters *)requestParameters callBack:(void (^_Nonnull)(MVMCoreRequestParameters * _Nonnull requestParameters))callback; -// Logs the action. Currently is not action information driven... depends on delegate. +/// Logs the action. Currently is not action information driven... depends on delegate. - (void)logAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Tries to open a page +/// Tries to open a page - (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// restarts the app +/// restarts the app - (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Goes back +/// Goes back - (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Makes a phone call +/// Makes a phone call - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Makes the previous request, needs the delegate for this +/// Makes the previous request, needs the delegate for this - (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Redirects to another experience +/// Redirects to another experience - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Cancels (like in a popup) +/// Cancels (like in a popup) - (void)cancelAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Goes to settings app +/// Goes to settings app - (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; /// Performs multiple actions - (void)actions:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Subclass this to handle other custom actions. Return YES if handled, and NO if not. +/// Subclass this to handle other custom actions. Return YES if handled, and NO if not. - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Last chance to handle unknown actions before throwing an error +/// Last chance to handle unknown actions before throwing an error - (void)unknownAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Handles action errors. +/// Handles action errors. - (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; #pragma mark - Link away action -// Links away to app or browser +/// Links away to app or browser - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Can subclass to add to urls if needed at global level (delegate is also called) +/// Can subclass to add to urls if needed at global level (delegate is also called) - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Opens the url +/// Opens the url - (void)openURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// opens the url in a webview. +/// opens the url in a webview. - (void)openURLInWebView:(nullable NSURL *)url actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; #pragma mark - Default Action Protocol Functions -// Currently no default log action but this will eventually be server driven. +/// Currently no default log action but this will eventually be server driven. + (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Sends the request to the load handler. +/// Sends the request to the load handler. + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// By default, throws an error, calling defaultHandleActionError. +/// By default, throws an error, calling defaultHandleActionError. + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Logs the error. +/// Logs the error. - (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData; #pragma mark - Deprecated -// Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values +/// Convenience function for handling actions. This will pull action and pageInfo out of the dictionary and call handleAction: actionInformation: with those values - (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; @end From 6a57e6b90382c829b17d118a9b32d4c08c20e5de Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 25 Jan 2021 11:13:15 -0500 Subject: [PATCH 057/150] actions mapped --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 4 +++- MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h | 1 + MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m | 1 + MVMCore/MVMCore/Models/ModelMapping.swift | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 7bb2a11..f4c389d 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -84,7 +84,9 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSettings]) { [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else if ([actionType isEqualToString:KeyActionTypeNoop]){ + } else if ([actionType isEqualToString:KeyActionTypeNoop]) { + } else if ([actionType isEqualToString:KeyActionTypeActions]) { + [self actions:actionInformation additionalData:additionalData delegateObject:delegateObject]; } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) { // not a known action type. [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index 220b180..c2d7f8e 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -40,6 +40,7 @@ extern NSString * const KeyActionTypeCancel; extern NSString * const KeyActionTypeRedirect; extern NSString * const KeyActionTypeSettings; extern NSString * const KeyActionTypeNoop; +extern NSString * const KeyActionTypeActions; extern NSString * const KeyActionInformation; extern NSString * const KeyLinkAwayAppURL; extern NSString * const KeyLinkAwayURL; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 2127e2e..80317ea 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -40,6 +40,7 @@ NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; NSString * const KeyActionTypeSettings = @"openSettings"; NSString * const KeyActionTypeNoop = @"noop"; +NSString * const KeyActionTypeActions = @"actions"; NSString * const KeyActionInformation = @"actionInformation"; NSString * const KeyLinkAwayAppURL = @"appURL"; NSString * const KeyLinkAwayURL = @"browserUrl"; diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 74acf80..6c3df04 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -21,5 +21,6 @@ import Foundation try? ModelRegistry.register(ActionCancelModel.self) try? ModelRegistry.register(ActionSettingModel.self) try? ModelRegistry.register(ActionNoopModel.self) + try? ModelRegistry.register(ActionActionsModel.self) } } From d7da39ce25ac53ee08a19b07346fa0b5429d7a37 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 28 Jan 2021 11:46:27 -0500 Subject: [PATCH 058/150] Adds url and base url for open page. --- .../MVMCore/LoadHandling/MVMCoreLoadHandler.m | 48 +++++++++---------- .../LoadHandling/MVMCoreRequestParameters.h | 11 +++-- .../LoadHandling/MVMCoreRequestParameters.m | 9 ++++ .../ActionType/ActionOpenPageModel.swift | 3 ++ 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index db3673f..27043bf 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -110,34 +110,32 @@ - (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error { - NSURL *url = nil; - - if (requestParameters.alternateBaseURL) { - url = requestParameters.alternateBaseURL; - } else { - url = [MVMCoreSessionObject sharedGlobal].baseURL; - } - + NSURL *url = requestParameters.URL; if (!url) { - url = [NSURL URLWithString:URLProdPostpayBase]; + if (requestParameters.alternateBaseURL) { + url = requestParameters.alternateBaseURL; + } else { + url = [MVMCoreSessionObject sharedGlobal].baseURL ?: [NSURL URLWithString:URLProdPostpayBase]; + } + + // Appends the context root. + if (requestParameters.contextRoot) { + url = [url URLByAppendingPathComponent:requestParameters.contextRoot]; + } else if ([MVMCoreSessionObject sharedGlobal].contextRoot) { + url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot]; + } + + // Appends the page type + if (requestParameters.pageType) { + url = [url URLByAppendingPathComponent:requestParameters.pageType]; + } + + // This has changed since the initial agreement. Seems server always needs page type now. + /* else if (requestParameters.modules) { + url = [url URLByAppendingPathComponent:KeyModuleMap]; + }*/ } - // Appends the context root. - if (requestParameters.contextRoot) { - url = [url URLByAppendingPathComponent:requestParameters.contextRoot]; - } else if ([MVMCoreSessionObject sharedGlobal].contextRoot) { - url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot]; - } - - // Appends the page type - if (requestParameters.pageType) { - url = [url URLByAppendingPathComponent:requestParameters.pageType]; - } - // This has changed since the initial agreement. Seems server always needs page type now. - /* else if (requestParameters.modules) { - url = [url URLByAppendingPathComponent:KeyModuleMap]; - }*/ - // Adds modules needed to the request parameters. if (requestParameters.modules.count > 0) { [requestParameters addRequestParameters:@{KeyModuleList:requestParameters.modules}]; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index 15163a0..07768d8 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -36,9 +36,15 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // adding parent pageType for freebee @property (nullable, strong, nonatomic) NSString *parentPageType; -// Context root for server +/// App context to use when building the url. For ex: https://baseURL/appContext/pageType @property (nullable, strong, nonatomic) NSString *contextRoot; +/// Host to use when building the url. For ex: https://baseURL/appContext/pageType +@property (nullable, strong, nonatomic) NSURL *alternateBaseURL; + +/// Entire URL to use instead of building the url +@property (nullable, strong, nonatomic) NSURL *URL; + // A flag for if you do not want to try loading any actual view controller. (Unless there is an error screen) @property (assign, nonatomic) BOOL noViewControllerToLoad; @@ -82,9 +88,6 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // If the request was created with an action map. @property (nullable, strong, nonatomic) NSDictionary *actionMap; -// only used when the base url is not the same as mf -@property (nullable, strong, nonatomic) NSURL *alternateBaseURL; - @property (nullable, strong, nonatomic) NSNumber *customTimeoutTime; // Will open support panel at the end of the load. diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m index f2e689f..5279dcc 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m @@ -66,6 +66,14 @@ if (self = [self initWithPageType:[actionMap stringForKey:KeyPageType] additionalModules:[actionMap array:KeyModuleList] extraParameters:[actionMap dict:KeyExtraParameters]]) { self.contextRoot = [actionMap string:KeyContextRoot]; + NSString *alternateBase = [actionMap string:@"baseURL"]; + if (alternateBase) { + self.alternateBaseURL = [NSURL URLWithString:[alternateBase stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]]; + } + NSString *url = [actionMap string:@"URL"]; + if (url) { + self.URL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + } self.actionMap = actionMap; self.customTimeoutTime = [actionMap optionalNumberForKey:@"customTimeoutTime"]; self.openSupportPanel = [actionMap boolForKey:KeyOpenSupport]; @@ -136,6 +144,7 @@ copyObject.imageData = self.imageData; copyObject.customTimeoutTime = self.customTimeoutTime; copyObject.backgroundRequest = self.backgroundRequest; + copyObject.URL = self.URL; return copyObject; } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index a20d343..69adbdc 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -15,6 +15,9 @@ public static var identifier: String = "openPage" public var actionType: String = ActionOpenPageModel.identifier public var pageType: String + public var baseURL: String? + public var appContext: String? + public var URL: String? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? public var presentationStyle: String? From 252d96e20cf0a30aef6a6987cb880a89a0c2bfb9 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 28 Jan 2021 11:59:09 -0500 Subject: [PATCH 059/150] comment update --- MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index 07768d8..df2aa69 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -36,10 +36,10 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // adding parent pageType for freebee @property (nullable, strong, nonatomic) NSString *parentPageType; -/// App context to use when building the url. For ex: https://baseURL/appContext/pageType +/// App context to use when building the url. For ex: baseURL/appContext/pageType @property (nullable, strong, nonatomic) NSString *contextRoot; -/// Host to use when building the url. For ex: https://baseURL/appContext/pageType +/// Base URL to use when building the url. For ex: baseURL/appContext/pageType @property (nullable, strong, nonatomic) NSURL *alternateBaseURL; /// Entire URL to use instead of building the url From 51ecaf481aa570e2f53cbdc98847fc3d21e93cc3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 28 Jan 2021 15:47:15 -0500 Subject: [PATCH 060/150] video molecule BGVideoImageMolecule --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h | 11 ++++ MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 55 ++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h index 0289b31..ca15d8d 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h @@ -9,6 +9,8 @@ #import #import +#import +@class MVMCoreErrorObject; //block returned when getting image //parameters are UIImage object for the image, NSData for gif images, UIImage object for the image, A BOOL to indicate if it is a fall back image. @@ -152,4 +154,13 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO // clears the image cache - (void)clearImageCache; +#pragma mark - Video Functions + +/// Loads an AVPlayerAsset from the shared asset cache. Uses default track keys of "duration" and "playable". +- (void)playerAssetFromFileName:(nonnull NSString *)filename onComplete:(void(^_Nonnull)(AVAsset * _Nullable, NSString * _Nonnull, MVMCoreErrorObject * _Nullable))completionHandler; + +/// Loads an AVPlayerAsset from the shared asset cache. +- (void)playerAssetFromFileName:(nonnull NSString *)filename trackKeys:(nonnull NSArray *)trackKeys onComplete:(void(^_Nonnull)(AVAsset * _Nullable, NSString * _Nonnull, MVMCoreErrorObject * _Nullable))completionHandler; + + @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index 27eabb9..c402552 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -15,6 +15,8 @@ #import "MVMCoreConstants.h" #import "MVMCoreActionUtility.h" #import "MVMCoreLoggingHandler.h" +#import "MVMCoreDispatchUtility.h" +#import "MVMCoreErrorConstants.h" @interface MVMCoreCache () @@ -34,6 +36,9 @@ // For thread safety @property (strong, nonatomic) dispatch_queue_t imageCacheQueue; +@property (nonnull, strong, nonatomic) dispatch_queue_t videoQueue; + +@property (nullable, strong, nonatomic) NSCache *playerItemCache; @end @@ -58,6 +63,9 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; self.imageCacheQueue = dispatch_queue_create("imgCache", DISPATCH_QUEUE_CONCURRENT); self.imageBundles = [NSMutableArray array]; + + self.videoQueue = dispatch_queue_create("video_queue", dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INTERACTIVE, 0)); + self.playerItemCache = [[NSCache alloc] init]; } return self; } @@ -664,6 +672,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; dispatch_barrier_async(self.imageCacheQueue, ^{ [self.imgCache removeAllObjects]; }); + [self.playerItemCache removeAllObjects]; } - (void)removeImageFromCache:(nonnull NSString *)imageName { @@ -691,4 +700,50 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; } } +#pragma mark - Video Functions + +- (void)playerAssetFromFileName:(NSString *)filename onComplete:(void(^)(AVAsset * _Nullable, NSString * _Nonnull, MVMCoreErrorObject * _Nullable))completionHandler { + [self playerAssetFromFileName:filename trackKeys:@[@"playable",@"duration"] onComplete:completionHandler]; +} + +- (void)playerAssetFromFileName:(NSString *)filename trackKeys:(NSArray *)trackKeys onComplete:(void(^)(AVAsset * _Nullable, NSString * _Nonnull, MVMCoreErrorObject * _Nullable))completionHandler { + [MVMCoreDispatchUtility performBlock:^{ + //get the video url, can be downloaded or assets + NSURL *url; + MVMCoreErrorObject *error = nil; + __block AVAsset *item = [self.playerItemCache objectForKey:filename]; + if (!item) { + if ([filename hasPrefix:@"http"]) { + url = [NSURL URLWithString:filename]; + } else { + url = [[MVMCoreGetterUtility bundleForMVMCore] URLForResource:filename withExtension:@"mp4"]; + } + if (url) { + item = [AVURLAsset URLAssetWithURL:url options:@{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}]; + [self.playerItemCache setObject:item forKey:filename]; // Set initial vanilla AVURLAsset. + } else { + error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[NSString stringWithFormat:@"Invalid URL: %@", filename] code:0 domain:ErrorDomainNative location:nil]; + } + } else { + MVMCoreLog(@"Loading video from cache: %@", filename); + } + + if (!item) { + if (!error) { + error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[NSString stringWithFormat:@"Failed to initialize asset for URL: %@", filename] code:0 domain:ErrorDomainNative location:nil]; + } + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + completionHandler(nil, filename, error); + }]; + } else { + // Load the duration key up front off of the main thread. Later duration will be used for seek and loop calculations. + [item loadValuesAsynchronouslyForKeys:trackKeys completionHandler:^{ + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + completionHandler(item, filename, error); + }]; + }]; + } + } onQueue:self.videoQueue]; +} + @end From 5cdb0414bbb20ed1d4a6c04c029f7c7e790c0b21 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 29 Jan 2021 10:18:20 -0500 Subject: [PATCH 061/150] optional modules --- .../MVMCoreLoadRequestOperation.m | 52 +++++++++++-------- .../LoadHandling/MVMCoreRequestParameters.h | 4 ++ .../LoadHandling/MVMCoreRequestParameters.m | 6 +++ 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 966700a..29f35b3 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -191,29 +191,32 @@ // Never use the cache. completionHandler(nil,nil); - } else if (requestParameters.pageType.length != 0 && requestParameters.modules.count > 0) { + } else { + NSArray *modules = [requestParameters allModules]; + if (requestParameters.pageType.length != 0 && modules.count > 0) { - // Check cache function for page json is already in the cache. - [[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + // Check cache function for page json is already in the cache. + [[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - // Check cache function for modules already in the cache. - NSDictionary *pageDictionary = jsonDictionary; - [[MVMCoreCache sharedCache] fetchJSONForModules:requestParameters.modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - completionHandler(pageDictionary,jsonDictionary); + // Check cache function for modules already in the cache. + NSDictionary *pageDictionary = jsonDictionary; + [[MVMCoreCache sharedCache] fetchJSONForModules:modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + completionHandler(pageDictionary,jsonDictionary); + }]; }]; - }]; - } else if (requestParameters.pageType.length != 0) { + } else if (requestParameters.pageType.length != 0) { - // Check cache function if page json is already in the cache. - [[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - completionHandler(jsonDictionary,nil); - }]; - } else if (requestParameters.modules.count > 0) { - - // Check cache function if modules already in the cache. - [[MVMCoreCache sharedCache] fetchJSONForModules:requestParameters.modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - completionHandler(nil,jsonDictionary); - }]; + // Check cache function if page json is already in the cache. + [[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + completionHandler(jsonDictionary,nil); + }]; + } else if (modules > 0) { + + // Check cache function if modules already in the cache. + [[MVMCoreCache sharedCache] fetchJSONForModules:modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + completionHandler(nil,jsonDictionary); + }]; + } } } @@ -239,16 +242,21 @@ // Check if the page was found in the cache. BOOL pageNotInCache = loadObject.operation.requestParameters.pageType && !loadObject.pageDataFromCache; - // Check all modules were found in the cache + // Check all required modules were found in the cache NSMutableArray *modulesNotInCache = [NSMutableArray array]; - for (NSString *module in loadObject.operation.requestParameters.modules) { + NSMutableArray *requiredModules = [NSMutableArray arrayWithArray:loadObject.operation.requestParameters.modules]; + for (NSString *module in [loadObject.operation.requestParameters allModules]) { if (![loadObject.modulesJSON objectForKey:module]) { + // Missing a module. [modulesNotInCache addObject:module]; + } else { + // Received a required module. + [requiredModules removeObject:module]; } } MVMCoreRequestParameters *requestParametersForServer = nil; - if (pageNotInCache || modulesNotInCache.count > 0) { + if (pageNotInCache || requiredModules.count > 0) { // We are missing data, will need to go to server. requestParametersForServer = [loadObject.operation.requestParameters copy]; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index df2aa69..7dbe729 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -29,6 +29,7 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // request parameters @property (nullable, strong, nonatomic) NSString *pageType; +@property (nullable, strong, nonatomic) NSArray *optionalModules; @property (nullable, strong, nonatomic) NSArray *modules; @property (nullable, strong, nonatomic) NSDictionary *parameters; @property (nullable, strong, nonatomic) NSData *imageData; @@ -120,4 +121,7 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // Sets the load style based on the server sent presentationStyle - (void)setMFLoadStyleBasedOnPresentationStyle:(nonnull NSString *)presentationStyle; +/// Returns optional and required modules +- (nullable NSArray *)allModules; + @end diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m index 5279dcc..b8e5877 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m @@ -116,6 +116,12 @@ } } +- (nullable NSArray *)allModules { + NSMutableSet *set = [NSMutableSet setWithArray:self.optionalModules]; + [set addObjectsFromArray:self.modules]; + return [set allObjects]; +} + - (id)copyWithZone:(nullable NSZone *)zone { MVMCoreRequestParameters *copyObject = [[MVMCoreRequestParameters alloc] init]; From 6f0735ed0265106d1cb01a875c8d3c3d3d8e0f21 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 29 Jan 2021 11:11:15 -0500 Subject: [PATCH 062/150] Warning fix --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index f4c389d..ddb1fab 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -395,7 +395,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else { [MVMCoreDispatchUtility performBlockInBackground:^{ // Cannot linkaway, show error. - MVMCoreErrorObject *error = error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeLinkAway]]; + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeLinkAway]]; [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; }]; } diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m index 5279dcc..d90af0a 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m @@ -68,11 +68,11 @@ self.contextRoot = [actionMap string:KeyContextRoot]; NSString *alternateBase = [actionMap string:@"baseURL"]; if (alternateBase) { - self.alternateBaseURL = [NSURL URLWithString:[alternateBase stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]]; + self.alternateBaseURL = [NSURL URLWithString:alternateBase]; } NSString *url = [actionMap string:@"URL"]; if (url) { - self.URL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + self.URL = [NSURL URLWithString:url]; } self.actionMap = actionMap; self.customTimeoutTime = [actionMap optionalNumberForKey:@"customTimeoutTime"]; From 9a1dd39dffbac9a6ee3f7a214fe4a39a71a397fe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 4 Feb 2021 17:09:53 -0500 Subject: [PATCH 063/150] optional modules --- MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h | 6 +++--- MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index 7dbe729..2e52a05 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -29,8 +29,8 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // request parameters @property (nullable, strong, nonatomic) NSString *pageType; -@property (nullable, strong, nonatomic) NSArray *optionalModules; -@property (nullable, strong, nonatomic) NSArray *modules; +@property (nullable, strong, nonatomic) NSArray *optionalModules; +@property (nullable, strong, nonatomic) NSArray *modules; @property (nullable, strong, nonatomic) NSDictionary *parameters; @property (nullable, strong, nonatomic) NSData *imageData; @@ -122,6 +122,6 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { - (void)setMFLoadStyleBasedOnPresentationStyle:(nonnull NSString *)presentationStyle; /// Returns optional and required modules -- (nullable NSArray *)allModules; +- (nullable NSArray *)allModules; @end diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m index 3ba9319..c4327e1 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m @@ -33,7 +33,8 @@ - (nullable instancetype)initWithPageType:(nonnull NSString *)pageType extraParameters:(nullable NSDictionary *)extraParameters { if (self = [self initWithExtraParameters:extraParameters]) { self.pageType = pageType; - self.modules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] allModulesForPageType:pageType]; + self.optionalModules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] modulesOptionalForPageType:pageType]; + self.modules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] modulesRequiredForPageType:pageType]; } return self; } @@ -127,7 +128,7 @@ MVMCoreRequestParameters *copyObject = [[MVMCoreRequestParameters alloc] init]; copyObject.pageType = [self.pageType copy]; copyObject.parentPageType = self.parentPageType; - + copyObject.optionalModules = [self.optionalModules copy]; copyObject.modules = [self.modules copy]; copyObject.parameters = [self.parameters copy]; copyObject.contextRoot = [self.contextRoot copy]; From 2ee96bf6d9e595eb078603c01c5edad226f842d3 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 19 Feb 2021 20:58:47 -0500 Subject: [PATCH 064/150] QIP --- .../ActionHandling/MVMCoreActionHandler.h | 2 +- .../ActionHandling/MVMCoreActionHandler.m | 54 ++++++++++++++----- .../LoadHandling/MVMCoreRequestParameters.h | 2 + .../ClientParameterProtocol.swift | 2 +- .../ClientParameterRegistry.swift | 19 ++++--- .../MFHardCodedServerResponse.h | 2 +- 6 files changed, 56 insertions(+), 25 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 2f41e93..6e272d4 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -32,7 +32,7 @@ extern NSString * _Nonnull const KeyActionTypeOpen; - (void)synchronouslyHandleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. -- (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler; +- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler; #pragma mark - Actions /// by default, returns the original RequestParameter that passed in. Can be overriden for some generic updates to the RequestParameter before handle open page action gets called. diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index ddb1fab..c7e3fc9 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -93,15 +93,15 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler { +- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler { - NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; + //NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; if (!clientParametersMap) { - completionHandler(actionInformation); + completionHandler(nil); return; } - BOOL isBackgroudRequest = [actionInformation boolForKey:@"background"]; + // BOOL isBackgroudRequest = [actionInformation boolForKey:@"background"]; if (!isBackgroudRequest) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading]; @@ -116,27 +116,28 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSError *error = nil; [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; [[[MVMCoreObject sharedInstance] clientParameterRegistry] getParametersWith:clientParametersMap + requestParameters:requestParameters error:&error completionHandler:^(NSDictionary * _Nullable clientParameters) { [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; if (clientParameters) { - NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; - NSMutableDictionary *extraParameters = [clientParameters mutableCopy]; - [extraParameters addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; - actionWithClientParameters[KeyExtraParameters] = extraParameters; + // NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; + // NSMutableDictionary *extraParameters = [clientParameters mutableCopy]; + // [extraParameters addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; + // actionWithClientParameters[KeyExtraParameters] = extraParameters; stopLoadingOverlay(); - completionHandler(actionWithClientParameters); + completionHandler(clientParameters); } else { [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; stopLoadingOverlay(); - completionHandler(actionInformation); + completionHandler(nil); } }]; if (error) { stopLoadingOverlay(); - completionHandler(actionInformation); + completionHandler(nil); [MVMCoreLoggingHandler addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler->setClientParameter"]]; } } @@ -172,6 +173,8 @@ NSString * const KeyActionTypeOpen = @"openPage"; void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionMap]; + requestParameters.clientParamters = [actionInformation dict:KeyClientParameters]; + [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; @@ -181,7 +184,10 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - [self setClientParameter:actionInformation completionHandler:performAction]; + // + //[self setClientParameter:actionInformation completionHandler:performAction]; + + performAction(actionInformation); } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -359,7 +365,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; }; - [self setClientParameter:actionInformation completionHandler:performAction]; + // [self setClientParameter:actionInformation completionHandler:performAction]; + [self setClientParameter:[actionInformation dict:KeyClientParameters] + requestParameters:nil + isBackgroudRequest:false + completionHandler:performAction]; } - (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -419,7 +429,23 @@ NSString * const KeyActionTypeOpen = @"openPage"; } + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject]; + // + + void (^performRequest)(MVMCoreRequestParameters*) = ^(MVMCoreRequestParameters* requestParametersB) { + [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParametersB dataForPage:additionalData delegateObject:delegateObject]; + }; + + if (requestParameters.clientParamters) { + [[MVMCoreActionHandler sharedActionHandler] setClientParameter:requestParameters.clientParamters + requestParameters: requestParameters.parameters + isBackgroudRequest: NO + completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { + [requestParameters addRequestParameters:jsonDictionary]; + performRequest(requestParameters); + }]; + } else { + performRequest(requestParameters); + } } + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index 2e52a05..705fc2b 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -89,6 +89,8 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // If the request was created with an action map. @property (nullable, strong, nonatomic) NSDictionary *actionMap; +@property (nullable, strong, nonatomic) NSDictionary *clientParamters; + @property (nullable, strong, nonatomic) NSNumber *customTimeoutTime; // Will open support panel at the end of the load. diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 2c689ec..62c543a 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,5 +11,5 @@ import Foundation public protocol ClientParameterProtocol { init() static var name: String { get } - func fetchClientParameters(for paramModel: ClientParameterModelProtocol, timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) + func fetchClientParameters(for paramModel: ClientParameterModelProtocol, requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 1a4160d..4c774c7 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -47,14 +47,14 @@ import Foundation /// ] ///} /// completionHandler can return flat dictinary or a map. It depends on the paramters handler - open func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { + open func getParameters(with clientParameters: [String: Any], requestParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { completionHandler(nil) return } - var parametersList: [String: Any] = [:] + var parametersList: [String: AnyHashable] = [:] let timeout = clientParameterModel.timeout ?? 30.0 let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") @@ -87,15 +87,18 @@ import Foundation parametersList[parameterModel.type] = ["error": defaultErrorString] group.enter() // Dispatch asynchronous injection. - self.getParameterFromHandler(parameterModel, before: timeout) { (receivedParameter) in + self.getParameterFromHandler(parameterModel, + requestParameters: requestParameters, + before: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { - if let receivedParameter = receivedParameter { - parametersList[parameterModel.type] = receivedParameter + if let receivedParameter = receivedParameter as? [String: AnyHashable] { + //parametersList[parameterModel.type] = receivedParameter + parametersList = parametersList.merging(receivedParameter) { (_, new) in new } } group.leave() // Leaving is only done after setup (barriered). } - } + } } // Callback when all parameters have been merged. @@ -103,11 +106,11 @@ import Foundation } } - func getParameterFromHandler( _ parameterModel: ClientParameterModelProtocol, before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { + func getParameterFromHandler( _ parameterModel: ClientParameterModelProtocol, requestParameters: [String: Any], before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { guard let parameterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } - parameterHandler.fetchClientParameters(for: parameterModel, timingOutIn: timeout, completionHandler: completionHandler) + parameterHandler.fetchClientParameters(for: parameterModel, requestParameters: requestParameters, timingOutIn: timeout, completionHandler: completionHandler) } /// Add all registry here. diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From dfa66d128284cab89c17b700f4dcefb8ce0711bc Mon Sep 17 00:00:00 2001 From: Nandhini Rajendran Date: Tue, 23 Feb 2021 15:19:17 +0530 Subject: [PATCH 065/150] Make reachability public --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index d181d1b..449ae7c 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -75,7 +75,7 @@ AF43A5871FBB67D6008E9347 /* MVMCoreActionUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A5851FBB67D6008E9347 /* MVMCoreActionUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A5861FBB67D6008E9347 /* MVMCoreActionUtility.m */; }; AF43A6F41FBCE21D008E9347 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AF43A6F31FBCE21D008E9347 /* libsqlite3.0.tbd */; }; - AF43A6FD1FBE2F65008E9347 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A6FA1FBE2F2A008E9347 /* Reachability.h */; }; + AF43A6FD1FBE2F65008E9347 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A6FA1FBE2F2A008E9347 /* Reachability.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A6FB1FBE2F2A008E9347 /* Reachability.m */; }; AF43A7011FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7001FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A7061FC4D7A2008E9347 /* MVMCoreObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7041FC4D7A2008E9347 /* MVMCoreObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; From 7996800b1710b1191b47a37a00cb41fea5418c24 Mon Sep 17 00:00:00 2001 From: Nandhini Rajendran Date: Thu, 25 Feb 2021 23:25:05 +0530 Subject: [PATCH 066/150] Exposing reachability to MVMCore.h --- MVMCore/MVMCore/MVMCore.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index ca0b8a0..c7fbd4a 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -36,6 +36,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import +#import // Mapping #import From 301e16697100821db2ceab6ece0baa5721f083f2 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 1 Mar 2021 18:23:48 -0500 Subject: [PATCH 067/150] merge --- .../ClientParameterModelProtocol.swift | 5 +++ .../ClientParameterRegistry.swift | 34 ++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift index b742170..dfda709 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift @@ -10,10 +10,15 @@ import Foundation public protocol ClientParameterModelProtocol: ModelProtocol { var type: String { get } + var isFlatMap: Bool? { get } } public extension ClientParameterModelProtocol { + var isFlatMap: Bool? { + return false + } + var type: String { get { Self.identifier } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 4c774c7..cfe5612 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -54,7 +54,6 @@ import Foundation return } - var parametersList: [String: AnyHashable] = [:] let timeout = clientParameterModel.timeout ?? 30.0 let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") @@ -64,16 +63,26 @@ import Foundation // Dispatch setup on queue to ensure setup is complete before completion callbacks. parametersWorkQueue.async(group: group, qos: .userInitiated) { [weak self] in guard let self = self else { return } + + var returnedList: [[String: AnyHashable]] = [] + var mergedParametersList: [String: AnyHashable] { + var parametersList: [String: AnyHashable] = [:] + for item in returnedList { + parametersList = parametersList.merging(item) { (_, new) in new } + } + return parametersList + } + // Setup completion handlers. Barriered to ensure one happens after the other. var complete = false let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { - completionHandler(parametersList); + completionHandler(mergedParametersList); complete = true } let completionWorkItem = DispatchWorkItem(qos: .userInitiated) { timeoutWorkItem.cancel() if !complete { // In the case of firing after timeout. - completionHandler(parametersList); + completionHandler(mergedParametersList); complete = true } } @@ -84,17 +93,23 @@ import Foundation // Setup the parameter execution. for parameterModel in clientParameterModel.list { // Setup default timeout / nil error. This will be replaced as parameters are collected. - parametersList[parameterModel.type] = ["error": defaultErrorString] + if !(parameterModel.isFlatMap ?? false) { + returnedList.append([parameterModel.type: ["error": defaultErrorString]]) + } group.enter() + // Dispatch asynchronous injection. self.getParameterFromHandler(parameterModel, requestParameters: requestParameters, before: timeout) { (receivedParameter) in + // Queue the results for merge. parametersWorkQueue.async { - if let receivedParameter = receivedParameter as? [String: AnyHashable] { - //parametersList[parameterModel.type] = receivedParameter - parametersList = parametersList.merging(receivedParameter) { (_, new) in new } + if parameterModel.isFlatMap ?? false, let receivedParameter = receivedParameter as? [String: AnyHashable] { + // parametersList = parametersList.merging(receivedParameter) { (_, new) in new } + returnedList.append(receivedParameter) + } else if let receivedParameter = receivedParameter { + returnedList.append([parameterModel.type: receivedParameter]) } group.leave() // Leaving is only done after setup (barriered). } @@ -110,7 +125,10 @@ import Foundation guard let parameterHandler = createParametersHandler(parameterModel.type) else { return completionHandler(nil) } - parameterHandler.fetchClientParameters(for: parameterModel, requestParameters: requestParameters, timingOutIn: timeout, completionHandler: completionHandler) + parameterHandler.fetchClientParameters(for: parameterModel, + requestParameters: requestParameters, + timingOutIn: timeout, + completionHandler: completionHandler) } /// Add all registry here. From b6c48edffd396e5ca736bdc20109524fffb3f75b Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Mon, 1 Mar 2021 18:28:02 -0500 Subject: [PATCH 068/150] remove hardcode --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 08142cb94568c39a56a201fc363273ba345fed79 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 2 Mar 2021 15:28:10 -0500 Subject: [PATCH 069/150] fix openurl --- .../ActionHandling/MVMCoreActionHandler.m | 25 ++++++++----------- .../MFHardCodedServerResponse.h | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index c7e3fc9..35fb29e 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -93,7 +93,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler { +- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable extraParameters))completionHandler { //NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; if (!clientParametersMap) { @@ -121,11 +121,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; completionHandler:^(NSDictionary * _Nullable clientParameters) { [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; if (clientParameters) { - // NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; - // NSMutableDictionary *extraParameters = [clientParameters mutableCopy]; - // [extraParameters addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; - // actionWithClientParameters[KeyExtraParameters] = extraParameters; - stopLoadingOverlay(); completionHandler(clientParameters); } else { @@ -184,9 +179,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; }; - // - //[self setClientParameter:actionInformation completionHandler:performAction]; - performAction(actionInformation); } @@ -346,26 +338,31 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { __weak typeof(self) weakSelf = self; - void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { + void (^performAction)(NSDictionary*) = ^(NSDictionary* extraParamters) { + + NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; + NSMutableDictionary *extraParametersT = [extraParamters mutableCopy]; + [extraParametersT addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; + actionWithClientParameters[KeyExtraParameters] = extraParametersT; + // Gets the app url NSURL *appURL = nil; - NSString *appURLString = [actionMap string:KeyLinkAwayAppURL]; + NSString *appURLString = [actionWithClientParameters string:KeyLinkAwayAppURL]; if (appURLString.length > 0) { appURL = [NSURL URLWithString:appURLString]; } // Gets the browser url NSURL *otherURL = nil; - NSString *otherURLString = [actionMap string:KeyLinkAwayURL]; + NSString *otherURLString = [actionWithClientParameters string:KeyLinkAwayURL]; if (otherURLString.length > 0) { otherURL = [NSURL URLWithString:otherURLString]; } // Provide the URL and App URL to be modified if needed by a subclass or delegate. - [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject]; + [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionWithClientParameters additionalData:additionalData delegateObject:delegateObject]; }; - // [self setClientParameter:actionInformation completionHandler:performAction]; [self setClientParameter:[actionInformation dict:KeyClientParameters] requestParameters:nil isBackgroudRequest:false diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 98f5f45322aebfc7c957fc936d2a2d89e0c8901f Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 3 Mar 2021 16:29:17 -0500 Subject: [PATCH 070/150] codereview --- .../ActionHandling/MVMCoreActionHandler.m | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 35fb29e..437faae 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -93,22 +93,19 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable extraParameters))completionHandler { +- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable extraParameters))completionHandler { - //NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters]; if (!clientParametersMap) { completionHandler(nil); return; } - - // BOOL isBackgroudRequest = [actionInformation boolForKey:@"background"]; - - if (!isBackgroudRequest) { + + if (showLoadingOverlay) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading]; } void (^stopLoadingOverlay)(void) = ^(void) { - if (!isBackgroudRequest) { + if (showLoadingOverlay) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:true]; } }; @@ -164,22 +161,17 @@ NSString * const KeyActionTypeOpen = @"openPage"; return; } - __weak typeof(self) weakSelf = self; - void (^performAction)(NSDictionary*) = ^(NSDictionary* actionMap) { - MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionMap]; + MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; - requestParameters.clientParamters = [actionInformation dict:KeyClientParameters]; + requestParameters.clientParamters = [actionInformation dict:KeyClientParameters]; - [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { - if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { - [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; - } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegateObject:delegateObject]; - } - }]; - }; - - performAction(actionInformation); + [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { + if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { + [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; + } else { + [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegateObject:delegateObject]; + } + }]; } - (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -365,7 +357,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [self setClientParameter:[actionInformation dict:KeyClientParameters] requestParameters:nil - isBackgroudRequest:false + showLoadingOverlay:true completionHandler:performAction]; } @@ -435,7 +427,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if (requestParameters.clientParamters) { [[MVMCoreActionHandler sharedActionHandler] setClientParameter:requestParameters.clientParamters requestParameters: requestParameters.parameters - isBackgroudRequest: NO + showLoadingOverlay: !requestParameters.backgroundRequest completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { [requestParameters addRequestParameters:jsonDictionary]; performRequest(requestParameters); From 7006ea83dfd3842e6a3acc76ca734f3059585643 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 4 Mar 2021 14:17:20 -0500 Subject: [PATCH 071/150] fix --- .../ActionHandling/MVMCoreActionHandler.h | 2 +- .../ActionHandling/MVMCoreActionHandler.m | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 6e272d4..616eb03 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -32,7 +32,7 @@ extern NSString * _Nonnull const KeyActionTypeOpen; - (void)synchronouslyHandleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. -- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters isBackgroudRequest:(BOOL)isBackgroudRequest completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler; +- (void)getClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler; #pragma mark - Actions /// by default, returns the original RequestParameter that passed in. Can be overriden for some generic updates to the RequestParameter before handle open page action gets called. diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 437faae..285b522 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -93,7 +93,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)setClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable extraParameters))completionHandler { +- (void)getClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable parameters))completionHandler { if (!clientParametersMap) { completionHandler(nil); @@ -355,7 +355,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionWithClientParameters additionalData:additionalData delegateObject:delegateObject]; }; - [self setClientParameter:[actionInformation dict:KeyClientParameters] + [self getClientParameter:[actionInformation dict:KeyClientParameters] requestParameters:nil showLoadingOverlay:true completionHandler:performAction]; @@ -417,23 +417,17 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Currently no default log action but this will eventually be server driven. } -+ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // - - void (^performRequest)(MVMCoreRequestParameters*) = ^(MVMCoreRequestParameters* requestParametersB) { - [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParametersB dataForPage:additionalData delegateObject:delegateObject]; - }; - ++ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { if (requestParameters.clientParamters) { - [[MVMCoreActionHandler sharedActionHandler] setClientParameter:requestParameters.clientParamters + [[MVMCoreActionHandler sharedActionHandler] getClientParameter:requestParameters.clientParamters requestParameters: requestParameters.parameters showLoadingOverlay: !requestParameters.backgroundRequest completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { [requestParameters addRequestParameters:jsonDictionary]; - performRequest(requestParameters); + [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject]; }]; } else { - performRequest(requestParameters); + [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject]; } } From 931d10f45ae062dd9536bbaa90a8a49f4bd59213 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Fri, 5 Mar 2021 17:23:06 -0500 Subject: [PATCH 072/150] enhancement --- .../ActionHandling/MVMCoreActionHandler.h | 2 +- .../ActionHandling/MVMCoreActionHandler.m | 21 +++--- .../LoadHandling/MVMCoreRequestParameters.h | 2 - .../ClientParameterProtocol.swift | 45 ++++++++++++- .../ClientParameterRegistry.swift | 64 +++++++++---------- 5 files changed, 87 insertions(+), 47 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 616eb03..d46fa63 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -97,7 +97,7 @@ extern NSString * _Nonnull const KeyActionTypeOpen; + (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; /// Sends the request to the load handler. -+ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; ++ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; /// By default, throws an error, calling defaultHandleActionError. + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 285b522..8b9a3aa 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -162,14 +162,14 @@ NSString * const KeyActionTypeOpen = @"openPage"; } MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; - - requestParameters.clientParamters = [actionInformation dict:KeyClientParameters]; - [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:additionalData]; } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegateObject:delegateObject]; + [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters + actionInformation:actionInformation + additionalData:additionalData + delegateObject:delegateObject]; } }]; } @@ -268,7 +268,10 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:dataForPage]; } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters additionalData:additionalData delegateObject:delegateObject]; + [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters + actionInformation:actionInformation + additionalData:additionalData + delegateObject:delegateObject]; } }]; }]; @@ -417,9 +420,11 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Currently no default log action but this will eventually be server driven. } -+ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - if (requestParameters.clientParamters) { - [[MVMCoreActionHandler sharedActionHandler] getClientParameter:requestParameters.clientParamters ++ (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + + NSDictionary *clientParamters = [actionInformation dict:KeyClientParameters]; + if (clientParamters) { + [[MVMCoreActionHandler sharedActionHandler] getClientParameter:clientParamters requestParameters: requestParameters.parameters showLoadingOverlay: !requestParameters.backgroundRequest completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h index 705fc2b..2e52a05 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.h @@ -89,8 +89,6 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) { // If the request was created with an action map. @property (nullable, strong, nonatomic) NSDictionary *actionMap; -@property (nullable, strong, nonatomic) NSDictionary *clientParamters; - @property (nullable, strong, nonatomic) NSNumber *customTimeoutTime; // Will open support panel at the end of the load. diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 62c543a..487f7c6 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -9,7 +9,48 @@ import Foundation public protocol ClientParameterProtocol { - init() static var name: String { get } - func fetchClientParameters(for paramModel: ClientParameterModelProtocol, requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) + + init() + init(_ clientParameterModel:ClientParameterModelProtocol) + + var isFlatMap: Bool { get } + var clientParameterModel:ClientParameterModelProtocol? { get set} + + func defaultErrorString() -> String + func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) + + /// The handler should call this methos to pass the paramter back to the caller. + func returnParameters(_ paramter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) + + /// Default parameter for timout scenarios. It will use the protocol extension method bydefault. Can override to send custom values. + func defaultValue() -> AnyHashable +} + +public extension ClientParameterProtocol { + var isFlatMap: Bool { false } + + func defaultErrorString() -> String { + return "failed_to_collect" + } + + func defaultValue() -> AnyHashable { + return [Self.name: defaultErrorString()] + } + + init(_ clientParameterModel:ClientParameterModelProtocol) { + self.init() + self.clientParameterModel = clientParameterModel + } + + func returnParameters(_ parameter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) { + guard let parameter = parameter else { + return completionHandler(nil) + } + if isFlatMap { + completionHandler(parameter) + } else { + completionHandler([Self.name :parameter]) + } + } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index cfe5612..eebc552 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -23,9 +23,9 @@ import Foundation mapping[T.name] = handler } - open func createParametersHandler(_ actionType: String) -> ClientParameterProtocol? { - guard let parameterType = mapping[actionType] else { return nil } - return parameterType.init() + open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { + guard let parameterType = mapping[clientParameterModel.type] else { return nil } + return parameterType.init(clientParameterModel) } static func getClientParameterModel(_ clientParameters: [String: Any]) throws -> ClientParameterModel? { @@ -58,17 +58,32 @@ import Foundation let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") let group = DispatchGroup() - let defaultErrorString = "failed_to_collect." + //let defaultErrorString = "failed_to_collect." // Dispatch setup on queue to ensure setup is complete before completion callbacks. parametersWorkQueue.async(group: group, qos: .userInitiated) { [weak self] in guard let self = self else { return } - var returnedList: [[String: AnyHashable]] = [] + var parameterHandlerList: [ClientParameterProtocol] = [] + var returnedList = [[String: AnyHashable]](repeating: [:], count: clientParameterModel.list.count) + + // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout + for parameterModel in clientParameterModel.list { + if let parameterHandler = self.createParametersHandler(parameterModel) { + parameterHandlerList.append(parameterHandler) + } + } + var mergedParametersList: [String: AnyHashable] { var parametersList: [String: AnyHashable] = [:] + var index = 0 for item in returnedList { - parametersList = parametersList.merging(item) { (_, new) in new } + if item.count == 0, let defaultValue = parameterHandlerList[index].defaultValue() as? [String: AnyHashable] { + parametersList = parametersList.merging(defaultValue) { (_, new) in new } + } else { + parametersList = parametersList.merging(item) { (_, new) in new } + } + index += 1 } return parametersList } @@ -89,31 +104,22 @@ import Foundation // Setup timeout. parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) - + // Setup the parameter execution. - for parameterModel in clientParameterModel.list { - // Setup default timeout / nil error. This will be replaced as parameters are collected. - if !(parameterModel.isFlatMap ?? false) { - returnedList.append([parameterModel.type: ["error": defaultErrorString]]) - } + var index = -1 + for parameterHandler in parameterHandlerList { group.enter() - - // Dispatch asynchronous injection. - self.getParameterFromHandler(parameterModel, - requestParameters: requestParameters, - before: timeout) { (receivedParameter) in - + index += 1 + parameterHandler.fetchClientParameters(requestParameters: requestParameters, + timingOutIn: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { - if parameterModel.isFlatMap ?? false, let receivedParameter = receivedParameter as? [String: AnyHashable] { - // parametersList = parametersList.merging(receivedParameter) { (_, new) in new } - returnedList.append(receivedParameter) - } else if let receivedParameter = receivedParameter { - returnedList.append([parameterModel.type: receivedParameter]) + if let receivedParameter = receivedParameter as? [String: AnyHashable] { + returnedList[index] = receivedParameter } group.leave() // Leaving is only done after setup (barriered). } - } + } } // Callback when all parameters have been merged. @@ -121,16 +127,6 @@ import Foundation } } - func getParameterFromHandler( _ parameterModel: ClientParameterModelProtocol, requestParameters: [String: Any], before timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) { - guard let parameterHandler = createParametersHandler(parameterModel.type) else { - return completionHandler(nil) - } - parameterHandler.fetchClientParameters(for: parameterModel, - requestParameters: requestParameters, - timingOutIn: timeout, - completionHandler: completionHandler) - } - /// Add all registry here. open func registerParameters() { } From c369958f5e5269c686eff67368125a55b39288a3 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 9 Mar 2021 14:22:13 -0500 Subject: [PATCH 073/150] review --- .../ClientParameterModelProtocol.swift | 5 ----- .../Client Parameters/ClientParameterProtocol.swift | 8 ++++---- .../Client Parameters/ClientParameterRegistry.swift | 11 +++-------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift index dfda709..b742170 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterModelProtocol.swift @@ -10,15 +10,10 @@ import Foundation public protocol ClientParameterModelProtocol: ModelProtocol { var type: String { get } - var isFlatMap: Bool? { get } } public extension ClientParameterModelProtocol { - var isFlatMap: Bool? { - return false - } - var type: String { get { Self.identifier } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 487f7c6..f6895e0 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -15,15 +15,15 @@ public protocol ClientParameterProtocol { init(_ clientParameterModel:ClientParameterModelProtocol) var isFlatMap: Bool { get } - var clientParameterModel:ClientParameterModelProtocol? { get set} + var clientParameterModel: ClientParameterModelProtocol? { get set } func defaultErrorString() -> String func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) - /// The handler should call this methos to pass the paramter back to the caller. + /// The handler should call this method to pass the parameter back to the caller. func returnParameters(_ paramter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) - /// Default parameter for timout scenarios. It will use the protocol extension method bydefault. Can override to send custom values. + /// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values. func defaultValue() -> AnyHashable } @@ -38,7 +38,7 @@ public extension ClientParameterProtocol { return [Self.name: defaultErrorString()] } - init(_ clientParameterModel:ClientParameterModelProtocol) { + init(_ clientParameterModel: ClientParameterModelProtocol) { self.init() self.clientParameterModel = clientParameterModel } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index eebc552..73644f9 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -58,7 +58,6 @@ import Foundation let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") let group = DispatchGroup() - //let defaultErrorString = "failed_to_collect." // Dispatch setup on queue to ensure setup is complete before completion callbacks. parametersWorkQueue.async(group: group, qos: .userInitiated) { [weak self] in @@ -76,14 +75,12 @@ import Foundation var mergedParametersList: [String: AnyHashable] { var parametersList: [String: AnyHashable] = [:] - var index = 0 - for item in returnedList { + for (index, item) in returnedList.enumerated() { if item.count == 0, let defaultValue = parameterHandlerList[index].defaultValue() as? [String: AnyHashable] { parametersList = parametersList.merging(defaultValue) { (_, new) in new } } else { parametersList = parametersList.merging(item) { (_, new) in new } } - index += 1 } return parametersList } @@ -106,10 +103,8 @@ import Foundation parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) // Setup the parameter execution. - var index = -1 - for parameterHandler in parameterHandlerList { - group.enter() - index += 1 + for (index, parameterHandler) in parameterHandlerList.enumerated() { + group.enter() parameterHandler.fetchClientParameters(requestParameters: requestParameters, timingOutIn: timeout) { (receivedParameter) in // Queue the results for merge. From 460d8b4dd9c02b5f2e133b683c230018be4e9b06 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Tue, 9 Mar 2021 16:56:48 -0500 Subject: [PATCH 074/150] review --- .../ClientParameterProtocol.swift | 31 +++++-------------- .../ClientParameterRegistry.swift | 10 +++--- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index f6895e0..a03f40d 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,39 +11,24 @@ import Foundation public protocol ClientParameterProtocol { static var name: String { get } - init() init(_ clientParameterModel:ClientParameterModelProtocol) - var isFlatMap: Bool { get } - var clientParameterModel: ClientParameterModelProtocol? { get set } + var clientParameterModel: ClientParameterModelProtocol { get set } - func defaultErrorString() -> String func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) - /// The handler should call this method to pass the parameter back to the caller. - func returnParameters(_ paramter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) - /// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values. - func defaultValue() -> AnyHashable + func valueOnTimeout() -> AnyHashable } public extension ClientParameterProtocol { - var isFlatMap: Bool { false } - - func defaultErrorString() -> String { - return "failed_to_collect" - } - - func defaultValue() -> AnyHashable { - return [Self.name: defaultErrorString()] - } - - init(_ clientParameterModel: ClientParameterModelProtocol) { - self.init() - self.clientParameterModel = clientParameterModel - } - func returnParameters(_ parameter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) { + func valueOnTimeout() -> AnyHashable { + return [Self.name: "failed_to_collect"] + } + + /// The handler should call this method to pass the parameter back to the caller. + func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) { guard let parameter = parameter else { return completionHandler(nil) } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 73644f9..3044a14 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -64,7 +64,7 @@ import Foundation guard let self = self else { return } var parameterHandlerList: [ClientParameterProtocol] = [] - var returnedList = [[String: AnyHashable]](repeating: [:], count: clientParameterModel.list.count) + var returnedList = [[String: AnyHashable]?](repeating: nil, count: clientParameterModel.list.count) // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout for parameterModel in clientParameterModel.list { @@ -76,10 +76,10 @@ import Foundation var mergedParametersList: [String: AnyHashable] { var parametersList: [String: AnyHashable] = [:] for (index, item) in returnedList.enumerated() { - if item.count == 0, let defaultValue = parameterHandlerList[index].defaultValue() as? [String: AnyHashable] { - parametersList = parametersList.merging(defaultValue) { (_, new) in new } - } else { + if let item = item { parametersList = parametersList.merging(item) { (_, new) in new } + } else if let defaultValue = parameterHandlerList[index].valueOnTimeout() as? [String: AnyHashable] { + parametersList = parametersList.merging(defaultValue) { (_, new) in new } } } return parametersList @@ -104,7 +104,7 @@ import Foundation // Setup the parameter execution. for (index, parameterHandler) in parameterHandlerList.enumerated() { - group.enter() + group.enter() parameterHandler.fetchClientParameters(requestParameters: requestParameters, timingOutIn: timeout) { (receivedParameter) in // Queue the results for merge. From 075ad5395388300bb28c739e19cbea276e5564a7 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 10 Mar 2021 11:20:36 -0500 Subject: [PATCH 075/150] fix --- .../ActionType/Client Parameters/ClientParameterProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index a03f40d..9d95876 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -11,7 +11,7 @@ import Foundation public protocol ClientParameterProtocol { static var name: String { get } - init(_ clientParameterModel:ClientParameterModelProtocol) + init(_ clientParameterModel: ClientParameterModelProtocol) var clientParameterModel: ClientParameterModelProtocol { get set } From ecac8ede70d0f7799fb6c8ac862980d4a9561e25 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 10 Mar 2021 13:03:44 -0500 Subject: [PATCH 076/150] map --- .../Client Parameters/ClientParameterProtocol.swift | 8 ++++---- .../Client Parameters/ClientParameterRegistry.swift | 7 +++---- .../HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 9d95876..0f6c843 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -15,20 +15,20 @@ public protocol ClientParameterProtocol { var clientParameterModel: ClientParameterModelProtocol { get set } - func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping (AnyHashable?) -> ()) + func fetchClientParameters(requestParameters: [String: Any], timingOutIn timeout: Double, completionHandler:@escaping ([String: AnyHashable]?) -> ()) /// Default parameter for timeout scenarios. It will use the protocol extension method bydefault. Can override to send custom values. - func valueOnTimeout() -> AnyHashable + func valueOnTimeout() -> [String: AnyHashable] } public extension ClientParameterProtocol { - func valueOnTimeout() -> AnyHashable { + func valueOnTimeout() -> [String: AnyHashable] { return [Self.name: "failed_to_collect"] } /// The handler should call this method to pass the parameter back to the caller. - func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping (AnyHashable?) -> ()) { + func returnParameters(_ isFlatMap: Bool, _ parameter: [String: AnyHashable]?, completionHandler: @escaping ([String: AnyHashable]?) -> ()) { guard let parameter = parameter else { return completionHandler(nil) } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 3044a14..996dfbc 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -78,7 +78,8 @@ import Foundation for (index, item) in returnedList.enumerated() { if let item = item { parametersList = parametersList.merging(item) { (_, new) in new } - } else if let defaultValue = parameterHandlerList[index].valueOnTimeout() as? [String: AnyHashable] { + } else { + let defaultValue = parameterHandlerList[index].valueOnTimeout() parametersList = parametersList.merging(defaultValue) { (_, new) in new } } } @@ -109,9 +110,7 @@ import Foundation timingOutIn: timeout) { (receivedParameter) in // Queue the results for merge. parametersWorkQueue.async { - if let receivedParameter = receivedParameter as? [String: AnyHashable] { - returnedList[index] = receivedParameter - } + returnedList[index] = receivedParameter group.leave() // Leaving is only done after setup (barriered). } } diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 4305b0a4da692793ad44ac22990f6e91b4089a32 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 10 Mar 2021 14:06:03 -0500 Subject: [PATCH 077/150] cleanup --- .../Client Parameters/ClientParameterProtocol.swift | 2 +- .../Client Parameters/ClientParameterRegistry.swift | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 0f6c843..2cf156b 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -35,7 +35,7 @@ public extension ClientParameterProtocol { if isFlatMap { completionHandler(parameter) } else { - completionHandler([Self.name :parameter]) + completionHandler([Self.name: parameter]) } } } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index 996dfbc..bfbbfd2 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -76,12 +76,8 @@ import Foundation var mergedParametersList: [String: AnyHashable] { var parametersList: [String: AnyHashable] = [:] for (index, item) in returnedList.enumerated() { - if let item = item { - parametersList = parametersList.merging(item) { (_, new) in new } - } else { - let defaultValue = parameterHandlerList[index].valueOnTimeout() - parametersList = parametersList.merging(defaultValue) { (_, new) in new } - } + let parameter = item ?? parameterHandlerList[index].valueOnTimeout() + parametersList = parametersList.merging(parameter) { (_, new) in new } } return parametersList } From 8ab8ada72d24d9168794010f3d3039cc095c01df Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 10 Mar 2021 17:06:21 -0500 Subject: [PATCH 078/150] fix --- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index bfbbfd2..a211675 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -64,7 +64,6 @@ import Foundation guard let self = self else { return } var parameterHandlerList: [ClientParameterProtocol] = [] - var returnedList = [[String: AnyHashable]?](repeating: nil, count: clientParameterModel.list.count) // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout for parameterModel in clientParameterModel.list { @@ -73,6 +72,8 @@ import Foundation } } + var returnedList = [[String: AnyHashable]?](repeating: nil, count: parameterHandlerList.count) + var mergedParametersList: [String: AnyHashable] { var parametersList: [String: AnyHashable] = [:] for (index, item) in returnedList.enumerated() { From c8f804abdb2289a9fd22555ce8eb4cad80e65029 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 11 Mar 2021 11:57:18 -0500 Subject: [PATCH 079/150] sms action --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 +++ .../ActionHandling/MVMCoreActionHandler.h | 3 ++ .../ActionHandling/MVMCoreActionHandler.m | 14 ++++++++ .../MVMCore/Constants/MVMCoreJSONConstants.h | 1 + .../MVMCore/Constants/MVMCoreJSONConstants.m | 1 + .../ActionType/ActionOpenSMSModel.swift | 33 +++++++++++++++++++ MVMCore/MVMCore/Models/ModelMapping.swift | 2 +- 7 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 449ae7c..fe05d49 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; + 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; 30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; }; @@ -167,6 +168,7 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionTimeHandler.m; sourceTree = ""; }; @@ -446,6 +448,7 @@ 94C014D824212360005811A9 /* ActionSettingModel.swift */, BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, ); path = ActionType; sourceTree = ""; @@ -885,6 +888,7 @@ 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */, D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */, AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, + 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */, 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */, 8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */, D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 2f41e93..14930a2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -50,6 +50,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; /// Goes back - (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +/// Opens Text Message +- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + /// Makes a phone call - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index ddb1fab..295d393 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -69,6 +69,9 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeCall]) { [self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } else if ([actionType isEqualToString:KeyActionTypeSMS]) { + [self smsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } else if ([actionType isEqualToString:KeyActionTypeShare]) { [self shareAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -261,6 +264,17 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } +/// Send Text Message +- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + + NSString *phoneNumber = [actionInformation stringForKey:KeyCallNumber]; + NSString *message = [actionInformation stringForKey:KeyMessage]; + NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; +// NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; +// [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; +} + - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Call NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index c2d7f8e..907feed 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -34,6 +34,7 @@ extern NSString * const KeyActionTypeBack; extern NSString * const KeyActionTypeShare; extern NSString * const KeyShareType; extern NSString * const KeyShareText; +extern NSString * const KeyActionTypeSMS; extern NSString * const KeyActionTypeCall; extern NSString * const KeyActionTypePreviousSubmit; extern NSString * const KeyActionTypeCancel; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 80317ea..a678877 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -35,6 +35,7 @@ NSString * const KeyActionTypeRestart = @"restart"; NSString * const KeyActionTypeBack = @"back"; NSString * const KeyActionTypeShare = @"share"; NSString * const KeyActionTypeCall = @"call"; +NSString * const KeyActionTypeSMS = @"sms"; NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift new file mode 100644 index 0000000..33fed5e --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift @@ -0,0 +1,33 @@ +// +// ActionOpenSMSModel.swift +// MVMCore +// +// Created by Kevin Christiano on 3/11/21. +// Copyright © 2021 myverizon. All rights reserved. +// + + +@objcMembers public class ActionOpenSMSModel: ActionModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "sms" + public var actionType: String = ActionCallModel.identifier + // TODO: decode into phone number once action handler is re-written + public var callNumber: String + public var message: String? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(callNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.callNumber = callNumber + self.message = message + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 6c3df04..f13e3e8 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -6,7 +6,6 @@ // Copyright © 2019 myverizon. All rights reserved. // -import Foundation @objcMembers public class ModelMapping: NSObject { @@ -22,5 +21,6 @@ import Foundation try? ModelRegistry.register(ActionSettingModel.self) try? ModelRegistry.register(ActionNoopModel.self) try? ModelRegistry.register(ActionActionsModel.self) + try? ModelRegistry.register(ActionOpenSMSModel.self) } } From e05eb5ebbed6f04f0a43ec7e0e1cbf26781394c2 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Mar 2021 15:21:24 -0500 Subject: [PATCH 080/150] handler fix --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 + .../ActionHandling/MVMCoreActionHandler.m | 4 +- .../ClientParameterHandler.swift | 108 ++++++++++++++++++ .../ClientParameterRegistry.swift | 98 +--------------- 4 files changed, 116 insertions(+), 98 deletions(-) create mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 449ae7c..a3ac7c6 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 016CF36925FA6DD400B82A1F /* ClientParameterHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */; }; 016FF6EE259A4E6300F5E4AA /* ClientParameterModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */; }; 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */; }; 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */; }; @@ -152,6 +153,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterHandler.swift; sourceTree = ""; }; 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModelProtocol.swift; sourceTree = ""; }; 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModel.swift; sourceTree = ""; }; 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = ""; }; @@ -309,6 +311,7 @@ 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */, 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */, 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */, + 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */, 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */, ); path = "Client Parameters"; @@ -857,6 +860,7 @@ AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */, AFED77A61FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.m in Sources */, + 016CF36925FA6DD400B82A1F /* ClientParameterHandler.swift in Sources */, AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */, 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */, AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 8b9a3aa..8072091 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -112,7 +112,9 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSError *error = nil; [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; - [[[MVMCoreObject sharedInstance] clientParameterRegistry] getParametersWith:clientParametersMap + + ClientParameterHandler* clientParameterHandler = [[ClientParameterHandler alloc] init]; + [clientParameterHandler getParametersWith:clientParametersMap requestParameters:requestParameters error:&error completionHandler:^(NSDictionary * _Nullable clientParameters) { diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift new file mode 100644 index 0000000..083724c --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -0,0 +1,108 @@ +// +// ClientParameterHandler.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 3/11/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + + +@objcMembers open class ClientParameterHandler: NSObject { + + var parameterHandlerList: [ClientParameterProtocol] = [] + let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter", autoreleaseFrequency: .workItem) + //DispatchQueue(label: "com.mva.clientparameter") + let group = DispatchGroup() + + open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { + guard let parameterType = MVMCoreObject.sharedInstance()?.clientParameterRegistry?.mapping[clientParameterModel.type] else { return nil } + return parameterType.init(clientParameterModel) + } + + func getClientParameterModel(_ clientParameters: [String: Any]) throws -> ClientParameterModel? { + let data = try JSONSerialization.data(withJSONObject: clientParameters) + return try JSONDecoder().decode(ClientParameterModel.self, from: data) + } + + /// Sample clientParameters + ///{ + /// "timeout": 30, + /// "list": [ + /// { + /// "type": "currentLocation", + /// "inputParameters": { + /// "accuracy": 10, + /// "timeThreshold": 600 + /// } + /// } + /// ] + ///} + /// completionHandler can return flat dictinary or a map. It depends on the paramters handler + open func getParameters(with clientParameters: [String: Any], requestParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { + + guard let clientParameterModel = try getClientParameterModel(clientParameters) else { + completionHandler(nil) + return + } + + let timeout = clientParameterModel.timeout ?? 30.0 + + + // Dispatch setup on queue to ensure setup is complete before completion callbacks. + parametersWorkQueue.async(group: group, qos: .userInitiated) { + // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout + for parameterModel in clientParameterModel.list { + if let parameterHandler = self.createParametersHandler(parameterModel) { + self.parameterHandlerList.append(parameterHandler) + } + } + + var returnedList = [[String: AnyHashable]?](repeating: nil, count: self.parameterHandlerList.count) + + var mergedParametersList: [String: AnyHashable] { + var parametersList: [String: AnyHashable] = [:] + for (index, item) in returnedList.enumerated() { + let parameter = item ?? self.parameterHandlerList[index].valueOnTimeout() + parametersList = parametersList.merging(parameter) { (_, new) in new } + } + return parametersList + } + + // Setup completion handlers. Barriered to ensure one happens after the other. + var complete = false + let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { + // Holding self. so that its not deallocated in the deispatch queue + completionHandler(mergedParametersList); + complete = true + } + let completionWorkItem = DispatchWorkItem(qos: .userInitiated) { + timeoutWorkItem.cancel() + if !complete { // In the case of firing after timeout. + completionHandler(mergedParametersList); + complete = true + } + } + + // Setup timeout. + self.parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) + + // Setup the parameter execution. + for (index, parameterHandler) in self.parameterHandlerList.enumerated() { + self.group.enter() + parameterHandler.fetchClientParameters(requestParameters: requestParameters, + timingOutIn: timeout) { (receivedParameter) in + // Queue the results for merge. + self.parametersWorkQueue.async { + returnedList[index] = receivedParameter + self.group.leave() // Leaving is only done after setup (barriered). + } + } + } + + // Callback when all parameters have been merged. + self.group.notify(queue: self.parametersWorkQueue, work: completionWorkItem); + } + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index a211675..bfb9410 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -11,8 +11,7 @@ import Foundation @objcMembers open class ClientParameterRegistry: NSObject { - private var mapping: [String: ClientParameterProtocol.Type] = [:] - + var mapping: [String: ClientParameterProtocol.Type] = [:] public override init() { super.init() @@ -23,101 +22,6 @@ import Foundation mapping[T.name] = handler } - open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { - guard let parameterType = mapping[clientParameterModel.type] else { return nil } - return parameterType.init(clientParameterModel) - } - - static func getClientParameterModel(_ clientParameters: [String: Any]) throws -> ClientParameterModel? { - let data = try JSONSerialization.data(withJSONObject: clientParameters) - return try JSONDecoder().decode(ClientParameterModel.self, from: data) - } - - /// Sample clientParameters - ///{ - /// "timeout": 30, - /// "list": [ - /// { - /// "type": "currentLocation", - /// "inputParameters": { - /// "accuracy": 10, - /// "timeThreshold": 600 - /// } - /// } - /// ] - ///} - /// completionHandler can return flat dictinary or a map. It depends on the paramters handler - open func getParameters(with clientParameters: [String: Any], requestParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws { - - guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else { - completionHandler(nil) - return - } - - let timeout = clientParameterModel.timeout ?? 30.0 - - let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") - let group = DispatchGroup() - - // Dispatch setup on queue to ensure setup is complete before completion callbacks. - parametersWorkQueue.async(group: group, qos: .userInitiated) { [weak self] in - guard let self = self else { return } - - var parameterHandlerList: [ClientParameterProtocol] = [] - - // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout - for parameterModel in clientParameterModel.list { - if let parameterHandler = self.createParametersHandler(parameterModel) { - parameterHandlerList.append(parameterHandler) - } - } - - var returnedList = [[String: AnyHashable]?](repeating: nil, count: parameterHandlerList.count) - - var mergedParametersList: [String: AnyHashable] { - var parametersList: [String: AnyHashable] = [:] - for (index, item) in returnedList.enumerated() { - let parameter = item ?? parameterHandlerList[index].valueOnTimeout() - parametersList = parametersList.merging(parameter) { (_, new) in new } - } - return parametersList - } - - // Setup completion handlers. Barriered to ensure one happens after the other. - var complete = false - let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { - completionHandler(mergedParametersList); - complete = true - } - let completionWorkItem = DispatchWorkItem(qos: .userInitiated) { - timeoutWorkItem.cancel() - if !complete { // In the case of firing after timeout. - completionHandler(mergedParametersList); - complete = true - } - } - - // Setup timeout. - parametersWorkQueue.asyncAfter(deadline: .now() + .seconds(Int(timeout)), execute: timeoutWorkItem) - - // Setup the parameter execution. - for (index, parameterHandler) in parameterHandlerList.enumerated() { - group.enter() - parameterHandler.fetchClientParameters(requestParameters: requestParameters, - timingOutIn: timeout) { (receivedParameter) in - // Queue the results for merge. - parametersWorkQueue.async { - returnedList[index] = receivedParameter - group.leave() // Leaving is only done after setup (barriered). - } - } - } - - // Callback when all parameters have been merged. - group.notify(queue: parametersWorkQueue, work: completionWorkItem); - } - } - /// Add all registry here. open func registerParameters() { } From 6b37f85ac3fdcb782a8f87da496fdb792424de83 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Mar 2021 15:26:11 -0500 Subject: [PATCH 081/150] remove comment --- .../ActionType/Client Parameters/ClientParameterHandler.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift index 083724c..1fd35d0 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -12,8 +12,7 @@ import Foundation @objcMembers open class ClientParameterHandler: NSObject { var parameterHandlerList: [ClientParameterProtocol] = [] - let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter", autoreleaseFrequency: .workItem) - //DispatchQueue(label: "com.mva.clientparameter") + let parametersWorkQueue = DispatchQueue(label: "com.mva.clientparameter") let group = DispatchGroup() open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { From 529bf5d447000c71ea0cc64086933f9f39141eb5 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Mar 2021 15:27:53 -0500 Subject: [PATCH 082/150] space --- .../ActionType/Client Parameters/ClientParameterRegistry.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift index bfb9410..ab3a488 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift @@ -26,7 +26,7 @@ import Foundation open func registerParameters() { } /// Register Default Core Client Paramter Objects - public func register(handler: T.Type, for model: M.Type) throws { + public func register(handler: T.Type, for model: M.Type) throws { try ModelRegistry.register(model) register(handler) } From 1670cd6c40433949114ecba9909cab2cecac07f2 Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Mar 2021 15:29:53 -0500 Subject: [PATCH 083/150] space --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 8072091..b534d2a 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -113,7 +113,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSError *error = nil; [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; - ClientParameterHandler* clientParameterHandler = [[ClientParameterHandler alloc] init]; + ClientParameterHandler *clientParameterHandler = [[ClientParameterHandler alloc] init]; [clientParameterHandler getParametersWith:clientParametersMap requestParameters:requestParameters error:&error From de10ed8eef3449ff66ba2aa826fbbe9c90a2e34d Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 11 Mar 2021 15:32:20 -0500 Subject: [PATCH 084/150] comment --- .../ActionType/Client Parameters/ClientParameterHandler.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift index 1fd35d0..1fb9cf3 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -50,6 +50,8 @@ import Foundation // Dispatch setup on queue to ensure setup is complete before completion callbacks. + + // Don't use [weak self]. Object is deallocated in the dispatch queue. parametersWorkQueue.async(group: group, qos: .userInitiated) { // Create the handler list so that same object can be used when merging. Merging needs default value in case of timeout for parameterModel in clientParameterModel.list { @@ -72,7 +74,6 @@ import Foundation // Setup completion handlers. Barriered to ensure one happens after the other. var complete = false let timeoutWorkItem = DispatchWorkItem(qos: .userInitiated) { - // Holding self. so that its not deallocated in the deispatch queue completionHandler(mergedParametersList); complete = true } From bad4c67e9e8aa5a3edc2199e3cac8cee95fc05fa Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 15 Mar 2021 16:39:46 -0500 Subject: [PATCH 085/150] added ModelHandlerProtocol Signed-off-by: Matt Bruce --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ++++ .../MVMCore/Models/Model/ModelHandlerProtocol.swift | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 MVMCore/MVMCore/Models/Model/ModelHandlerProtocol.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 449ae7c..afc5dae 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -149,6 +149,7 @@ D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */; }; D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCBA23C65BC300C44CC4 /* Percent.swift */; }; D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAD82260C3E400AEFD8C /* DelegateObject.swift */; }; + EA3B264C25FC0B7600008074 /* ModelHandlerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3B264B25FC0B7600008074 /* ModelHandlerProtocol.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -288,6 +289,7 @@ D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitInterval.swift; sourceTree = ""; }; D2DEDCBA23C65BC300C44CC4 /* Percent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Percent.swift; sourceTree = ""; }; D2E1FAD82260C3E400AEFD8C /* DelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelegateObject.swift; sourceTree = ""; }; + EA3B264B25FC0B7600008074 /* ModelHandlerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHandlerProtocol.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -404,6 +406,7 @@ 946EE1A8237B5C650036751F /* Model */ = { isa = PBXGroup; children = ( + EA3B264B25FC0B7600008074 /* ModelHandlerProtocol.swift */, 946EE1A2237B59C30036751F /* ModelProtocol.swift */, 946EE1A6237B5B1C0036751F /* ModelRegistry.swift */, ); @@ -869,6 +872,7 @@ 94C014D924212360005811A9 /* ActionSettingModel.swift in Sources */, D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */, 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */, + EA3B264C25FC0B7600008074 /* ModelHandlerProtocol.swift in Sources */, AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */, 946EE1A3237B59C30036751F /* ModelProtocol.swift in Sources */, AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */, diff --git a/MVMCore/MVMCore/Models/Model/ModelHandlerProtocol.swift b/MVMCore/MVMCore/Models/Model/ModelHandlerProtocol.swift new file mode 100644 index 0000000..522147b --- /dev/null +++ b/MVMCore/MVMCore/Models/Model/ModelHandlerProtocol.swift @@ -0,0 +1,11 @@ +// +// ModelViewProtocol.swift +// MVMCore +// +// Created by Matt Bruce on 3/12/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + +public protocol ModelHandlerProtocol {} From 473da43e6b4a84a2d9746927f05a38869cceda08 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 15 Mar 2021 16:40:22 -0500 Subject: [PATCH 086/150] refactored Category to include the mapping handler Dictionary added methods to register and get handlers --- .../MVMCore/Models/Model/ModelRegistry.swift | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 93407d1..deeb6ed 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -25,24 +25,59 @@ public struct ModelRegistry { var name: String var codingKey: String var instanceTypes: [String: ModelProtocol.Type] = [:] + var handlerTypes: [String: ModelHandlerProtocol.Type] = [:] } private static var categories: [String: Category] = [:] + + /// Registers models for Atomic use. + public static func register(handler: H.Type, for model: M.Type) throws { + //register the type + try self.register(model) + + //get the key for the handler + let key = model.identifier + + //get the category for the ModelProtocol + var category = getCategory(for: model) + + // Check to ensure the Category/Container combination doesn't exist. + if category.handlerTypes[key] != nil { + throw ModelRegistry.Error.other(message: "ModelHandlerProtocol: \(String(describing: handler)) already exists in Category: \(category.name)") + } else { + category.handlerTypes[key] = handler + } + categories[category.name] = category + } /// Registers models for Atomic use. public static func register(_ type: M.Type) throws { - - var category = categories[M.categoryName] ?? Category(name: M.categoryName, codingKey: M.categoryCodingKey) + //get the category for the ModelProtocol + var category = getCategory(for: type) // Check to ensure the Category/Type combination doesn't exist. if category.instanceTypes[M.identifier] != nil { throw ModelRegistry.Error.other(message: "ModelProtocol: \(M.identifier) already exists in Category: \(M.categoryName)") } - category.instanceTypes[M.identifier] = type categories[M.categoryName] = category } + public static func getHandler(_ model: ModelProtocol) -> ModelHandlerProtocol.Type? { + //get the modelType + let modelType = type(of: model) + + //get the category for the ModelProtocol + guard let category = categories[modelType.categoryName] else { return nil } + + //get the containerProtocol for this ModelProtocol you had registered + return category.handlerTypes[modelType.identifier] + } + + private static func getCategory(for type: M.Type) -> Category { + return categories[type.categoryName] ?? Category(name: type.categoryName, codingKey: type.categoryCodingKey) + } + private static func getCategory(for type: T.Type) -> Category? { // Temporary code till we find a better solution. //if this is a protocol composotion, loop through each protocol for a category lookup From 86819283c07223442f46f346ee4a3d60123b1d50 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 17 Mar 2021 11:37:01 -0400 Subject: [PATCH 087/150] improve locae check behavior --- MVMCore/MVMCore/Models/Model/ModelRegistry.swift | 1 - MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 93407d1..791e70e 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -7,7 +7,6 @@ // Copyright © 2019 myverizon. All rights reserved. // -import Foundation public struct ModelRegistry { diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index b48f34e..308016f 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -19,8 +19,13 @@ } + (BOOL)userPrefersSpanish { - // This should be enough for us to look at what the user prefers. - return [[[[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2] lowercaseString] isEqualToString:@"es"]; + // Gets preferences based on what the user wants and the app provides. + NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]; + if (languageCode && [languageCode length] > 2) { + return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"]; + } else { + return [[languageCode lowercaseString] isEqualToString:@"es"]; + } } + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { From 63abf3d35e596b7ad49e931b6b4d828c4072752a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 17 Mar 2021 11:46:09 -0400 Subject: [PATCH 088/150] updated comment --- MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index 308016f..8c76ba8 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -19,7 +19,7 @@ } + (BOOL)userPrefersSpanish { - // Gets preferences based on what the user wants and the app provides. + // Gets language code based on what the user prefers and the app provides. NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]; if (languageCode && [languageCode length] > 2) { return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"]; @@ -35,7 +35,6 @@ } else { return [[NSBundle bundleWithPath:[[MVMCoreGetterUtility bundleForMVMCore] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; - } } From e13530f5b45ed4cb5f03aa42392e2c3d12373524 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 17 Mar 2021 13:52:20 -0400 Subject: [PATCH 089/150] updating func --- .../Utility/Helpers/MVMCoreGetterUtility.h | 6 ++++++ .../Utility/Helpers/MVMCoreGetterUtility.m | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h index 262cc75..df18405 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h @@ -19,6 +19,12 @@ // Returns the hardcoded string from the string file. + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key; +// Return current system language ++ (nullable NSString *)getSystemLanguage; + +// Return current preferred system language ++ (nullable NSString *)getPreferredAvailableLanguage; + // Returns true if the user's language is Spanish + (BOOL)userPrefersSpanish; diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index 8c76ba8..0d2f8ef 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -18,15 +18,27 @@ return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCore"]; } +// Confirms that the preferred user language is for spanish users. + (BOOL)userPrefersSpanish { - // Gets language code based on what the user prefers and the app provides. - NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]; + + NSString *languageCode = [MVMCoreGetterUtility getPreferredAvailableLanguage]; if (languageCode && [languageCode length] > 2) { return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"]; } else { return [[languageCode lowercaseString] isEqualToString:@"es"]; } } + +// Gets language code based on what the user prefers and the app provides. ++ (NSString *)getPreferredAvailableLanguage { + + return [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]; +} + ++ (NSString *)getSystemLanguage { + + return [[NSLocale preferredLanguages] objectAtIndex:0]; +} + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { // If the app language is not english... force load from the english file anyway. From 7581c6609f2043f458f10ec1932fd53a047e13fb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 11:46:07 -0400 Subject: [PATCH 090/150] providing redirect --- .../Utility/Helpers/MVMCoreGetterUtility.h | 3 +++ .../Utility/Helpers/MVMCoreGetterUtility.m | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h index df18405..64feae8 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h @@ -19,6 +19,9 @@ // Returns the hardcoded string from the string file. + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key; +// Returns the hardcoded string from the string file based on module. ++ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key bundle:(nullable NSBundle *)bundle; + // Return current system language + (nullable NSString *)getSystemLanguage; diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index 0d2f8ef..a132316 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -35,19 +35,22 @@ return [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]; } +// Returns the preferred language set system wide. + (NSString *)getSystemLanguage { return [[NSLocale preferredLanguages] objectAtIndex:0]; } + (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key { + // Redirect key with relevant module. + return [MVMCoreGetterUtility hardcodedStringWithKey:key bundle:[MVMCoreGetterUtility bundleForMVMCore]]; +} + ++ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key bundle:(nullable NSBundle *)bundle { + // If the app language is not english... force load from the english file anyway. - if ([MVMCoreGetterUtility userPrefersSpanish]) { - return [[NSBundle bundleWithPath:[[MVMCoreGetterUtility bundleForMVMCore] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; - - } else { - return [[NSBundle bundleWithPath:[[MVMCoreGetterUtility bundleForMVMCore] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; - } + NSString *languageCode = [MVMCoreGetterUtility userPrefersSpanish] ? @"es" : @"en"; + return [[NSBundle bundleWithPath:[bundle pathForResource:languageCode ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]; } + (nonnull UIColor *)getColorForHexString:(nonnull NSString *)hexString { From ff0bde3fbff7bee3e5b99f78891819a1e4989a8e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 13:41:52 -0400 Subject: [PATCH 091/150] refactored --- MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index a132316..044f2d5 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -21,11 +21,11 @@ // Confirms that the preferred user language is for spanish users. + (BOOL)userPrefersSpanish { - NSString *languageCode = [MVMCoreGetterUtility getPreferredAvailableLanguage]; + NSString *languageCode = [[MVMCoreGetterUtility getPreferredAvailableLanguage] lowercaseString]; if (languageCode && [languageCode length] > 2) { - return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"]; + return [[languageCode substringToIndex:2] isEqualToString:@"es"]; } else { - return [[languageCode lowercaseString] isEqualToString:@"es"]; + return [languageCode isEqualToString:@"es"]; } } From f36f1e5142acf5d32eb3344a376fd5eac3d94f96 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 15:09:15 -0400 Subject: [PATCH 092/150] simpifying check --- MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index 044f2d5..c5a8570 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -21,12 +21,7 @@ // Confirms that the preferred user language is for spanish users. + (BOOL)userPrefersSpanish { - NSString *languageCode = [[MVMCoreGetterUtility getPreferredAvailableLanguage] lowercaseString]; - if (languageCode && [languageCode length] > 2) { - return [[languageCode substringToIndex:2] isEqualToString:@"es"]; - } else { - return [languageCode isEqualToString:@"es"]; - } + return [[[MVMCoreGetterUtility getPreferredAvailableLanguage] lowercaseString] hasPrefix:@"es"]; } // Gets language code based on what the user prefers and the app provides. From 69f908173c65c48dd83f0e72b3a9ed3ad420b053 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 23 Mar 2021 12:09:53 -0400 Subject: [PATCH 093/150] merging --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..efa33b6 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From 34055e87132d3531d4b8974d051217a9e24e3d9d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Mar 2021 15:31:01 -0400 Subject: [PATCH 094/150] key update --- MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m | 2 +- MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m index c4327e1..63f4f4f 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreRequestParameters.m @@ -71,7 +71,7 @@ if (alternateBase) { self.alternateBaseURL = [NSURL URLWithString:alternateBase]; } - NSString *url = [actionMap string:@"URL"]; + NSString *url = [actionMap string:@"requestURL"]; if (url) { self.URL = [NSURL URLWithString:url]; } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 69adbdc..c811414 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -17,7 +17,7 @@ public var pageType: String public var baseURL: String? public var appContext: String? - public var URL: String? + public var requestURL: String? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? public var presentationStyle: String? From dc421e7498d33aae33dceaa74ec204342280c839 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 30 Mar 2021 16:53:51 -0400 Subject: [PATCH 095/150] adding class contact --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 +++ .../ActionType/ActionMakeContactModel.swift | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 176463b..5fccb56 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; + 0ACC81A22613C73800A9C886 /* ActionMakeContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */; }; 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; 30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -171,6 +172,7 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; + 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionMakeContactModel.swift; sourceTree = ""; }; 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; @@ -455,6 +457,7 @@ BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, + 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */, ); path = ActionType; sourceTree = ""; @@ -856,6 +859,7 @@ 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, + 0ACC81A22613C73800A9C886 /* ActionMakeContactModel.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift new file mode 100644 index 0000000..d2f10d4 --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift @@ -0,0 +1,33 @@ +// +// ActionMakeContactModel.swift +// MVMCore +// +// Created by Kevin Christiano on 3/30/21. +// Copyright © 2021 myverizon. All rights reserved. +// + + +@objcMembers public class ActionMakeContactModel: ActionModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "contact" + public var actionType: String = ActionCallModel.identifier + // TODO: decode into phone number once action handler is re-written + public var callNumber: String + public var message: String? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(callNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.callNumber = callNumber + self.message = message + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} From f595e40f2ff5114c0de17f5078350e438ce39e4e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 30 Mar 2021 16:56:10 -0400 Subject: [PATCH 096/150] contact action. --- MVMCore/MVMCore/Models/ModelMapping.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index f13e3e8..b1bdd71 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -22,5 +22,7 @@ try? ModelRegistry.register(ActionNoopModel.self) try? ModelRegistry.register(ActionActionsModel.self) try? ModelRegistry.register(ActionOpenSMSModel.self) + try? ModelRegistry.register(ActionMakeContactModel.self) } } + From e5e2d334d85b84d6bf306f90ca639b3f0f6a7f58 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 31 Mar 2021 10:40:24 -0400 Subject: [PATCH 097/150] unify the many registries and mappers --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 -- .../ClientParameterHandler.swift | 5 +-- .../ClientParameterProtocol.swift | 2 +- .../ClientParameterRegistry.swift | 39 ------------------- MVMCore/MVMCore/Models/ModelMapping.swift | 6 +-- .../MVMCore/Session/MVMCoreSessionObject.m | 1 - MVMCore/MVMCore/Singletons/MVMCoreObject.h | 3 -- MVMCore/MVMCore/Singletons/MVMCoreObject.m | 2 +- 8 files changed, 5 insertions(+), 57 deletions(-) delete mode 100644 MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 8c2b4cb..ed82363 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -24,7 +24,6 @@ 016CF36925FA6DD400B82A1F /* ClientParameterHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */; }; 016FF6EE259A4E6300F5E4AA /* ClientParameterModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */; }; 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */; }; - 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */; }; 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */; }; 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; @@ -157,7 +156,6 @@ 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterHandler.swift; sourceTree = ""; }; 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModelProtocol.swift; sourceTree = ""; }; 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModel.swift; sourceTree = ""; }; - 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = ""; }; 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterProtocol.swift; sourceTree = ""; }; 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; @@ -312,7 +310,6 @@ 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */, 016FF6ED259A4E6300F5E4AA /* ClientParameterModelProtocol.swift */, 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */, - 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */, 016CF36825FA6DD400B82A1F /* ClientParameterHandler.swift */, 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */, ); @@ -872,7 +869,6 @@ 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */, AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */, AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */, - 016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */, 94C014D924212360005811A9 /* ActionSettingModel.swift in Sources */, D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */, 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift index 1fb9cf3..dc34e8e 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -6,9 +6,6 @@ // Copyright © 2021 myverizon. All rights reserved. // -import Foundation - - @objcMembers open class ClientParameterHandler: NSObject { var parameterHandlerList: [ClientParameterProtocol] = [] @@ -16,7 +13,7 @@ import Foundation let group = DispatchGroup() open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { - guard let parameterType = MVMCoreObject.sharedInstance()?.clientParameterRegistry?.mapping[clientParameterModel.type] else { return nil } + guard let parameterType = ModelRegistry.getHandler(clientParameterModel) as? ClientParameterProtocol.Type else { return nil } return parameterType.init(clientParameterModel) } diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift index 2cf156b..7f52778 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol ClientParameterProtocol { +public protocol ClientParameterProtocol: ModelHandlerProtocol { static var name: String { get } init(_ clientParameterModel: ClientParameterModelProtocol) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift deleted file mode 100644 index ab3a488..0000000 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterRegistry.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// ClientParameterRegistry.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 12/29/20. -// Copyright © 2020 myverizon. All rights reserved. -// - -import Foundation - - -@objcMembers open class ClientParameterRegistry: NSObject { - - var mapping: [String: ClientParameterProtocol.Type] = [:] - - public override init() { - super.init() - registerParameters() - } - - open func register(_ handler: T.Type) { - mapping[T.name] = handler - } - - /// Add all registry here. - open func registerParameters() { } - - /// Register Default Core Client Paramter Objects - public func register(handler: T.Type, for model: M.Type) throws { - try ModelRegistry.register(model) - register(handler) - } - - /// Register Default Core Client Paramter Objects - public static func register(handler: T.Type, for model: M.Type) throws { - try ModelRegistry.register(model) - MVMCoreObject.sharedInstance()?.clientParameterRegistry?.register(handler) - } -} diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 6c3df04..a50ee54 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -6,11 +6,9 @@ // Copyright © 2019 myverizon. All rights reserved. // -import Foundation - -@objcMembers public class ModelMapping: NSObject { +@objcMembers open class ModelMapping: NSObject { - public static func registerObjects() { + open class func registerObjects() { try? ModelRegistry.register(ActionOpenPageModel.self) try? ModelRegistry.register(ActionOpenUrlModel.self) try? ModelRegistry.register(ActionCallModel.self) diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m index 7134c59..bcdf390 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionObject.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionObject.m @@ -16,7 +16,6 @@ - (instancetype)init { if (self = [super init]) { self.session = [self createNSURLSession]; - [ModelMapping registerObjects]; } return self; } diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.h b/MVMCore/MVMCore/Singletons/MVMCoreObject.h index 023ad63..03a8411 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.h +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.h @@ -18,8 +18,6 @@ #import #import -@class ClientParameterRegistry; - @interface MVMCoreObject : NSObject @property (nullable, strong, nonatomic) MVMCoreSessionObject *session; @@ -28,7 +26,6 @@ @property (nullable, strong, nonatomic) MVMCoreActionHandler *actionHandler; @property (nullable, strong, nonatomic) MVMCoreSessionTimeHandler *sessionHandler; @property (nullable, strong, nonatomic) MVMCoreLoadHandler *loadHandler; -@property (nullable, strong, nonatomic) ClientParameterRegistry *clientParameterRegistry; // The delegates @property (nullable, strong, nonatomic) id globalLoadDelegate; diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.m b/MVMCore/MVMCore/Singletons/MVMCoreObject.m index 6b60d65..21eb44e 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.m +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.m @@ -21,6 +21,7 @@ } - (void)defaultInitialSetup { + [ModelMapping registerObjects]; self.session = [[MVMCoreSessionObject alloc] init]; self.cache = [[MVMCoreCache alloc] init]; self.viewControllerMapping = [[MVMCoreViewControllerMappingObject alloc] init]; @@ -28,7 +29,6 @@ self.actionHandler = [[MVMCoreActionHandler alloc] init]; self.loggingDelegate = [[MVMCoreLoggingHandler alloc] init]; self.loadHandler = [[MVMCoreLoadHandler alloc] init]; - self.clientParameterRegistry = [[ClientParameterRegistry alloc] init]; } @end From d4dfe2567b4a04a33622a0d927ba3fc4ae5423c7 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 31 Mar 2021 10:53:37 -0400 Subject: [PATCH 098/150] latest updates for fios additions. --- .../ActionHandling/MVMCoreActionHandler.m | 82 ++++++++++++------- .../MVMCore/Constants/MVMCoreJSONConstants.h | 4 + .../MVMCore/Constants/MVMCoreJSONConstants.m | 4 + .../ActionType/ActionMakeContactModel.swift | 8 +- .../MVMCore/Models/Model/ModelProtocol.swift | 5 +- 5 files changed, 65 insertions(+), 38 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 243ca70..9696494 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -71,10 +71,13 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSMS]) { [self smsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + + } else if ([actionType isEqualToString:KeyActionTypeContact]) { + [self contactAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; } else if ([actionType isEqualToString:KeyActionTypeShare]) { [self shareAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - + } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { [self previousSubmitAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -86,7 +89,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSettings]) { [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - + } else if ([actionType isEqualToString:KeyActionTypeNoop]) { } else if ([actionType isEqualToString:KeyActionTypeActions]) { [self actions:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -102,7 +105,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; completionHandler(nil); return; } - + if (showLoadingOverlay) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading]; } @@ -115,22 +118,22 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSError *error = nil; [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; - + ClientParameterHandler *clientParameterHandler = [[ClientParameterHandler alloc] init]; [clientParameterHandler getParametersWith:clientParametersMap - requestParameters:requestParameters - error:&error - completionHandler:^(NSDictionary * _Nullable clientParameters) { - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; - if (clientParameters) { - stopLoadingOverlay(); - completionHandler(clientParameters); - } else { - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; - stopLoadingOverlay(); - completionHandler(nil); - } - }]; + requestParameters:requestParameters + error:&error + completionHandler:^(NSDictionary * _Nullable clientParameters) { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; + if (clientParameters) { + stopLoadingOverlay(); + completionHandler(clientParameters); + } else { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; + stopLoadingOverlay(); + completionHandler(nil); + } + }]; if (error) { stopLoadingOverlay(); @@ -158,14 +161,14 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Loads the given page type. NSString *pageType = [actionInformation stringForKey:KeyPageType]; - + if (pageType.length == 0) { // No page type to load, show error. MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeOpen]]; [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; return; } - + MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { @@ -262,11 +265,28 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSString *phoneNumber = [actionInformation stringForKey:KeyCallNumber]; NSString *message = [actionInformation stringForKey:KeyMessage]; NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; -// NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; -// [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + // NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; } +- (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + + NSString *approach = [actionInformation stringForKey:@"approach"]; + + if ([approach isEqualToString:KeyAdd]) { + + } else if ([approach isEqualToString:KeyCreate]) { + + } + +// NSString *message = [actionInformation stringForKey:KeyMessage]; +// NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; + // NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; +// [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; +} + - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Call NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; @@ -347,33 +367,33 @@ NSString * const KeyActionTypeOpen = @"openPage"; #pragma mark - open url functions - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - + __weak typeof(self) weakSelf = self; void (^performAction)(NSDictionary*) = ^(NSDictionary* extraParamters) { - + NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; NSMutableDictionary *extraParametersT = [extraParamters mutableCopy]; [extraParametersT addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; actionWithClientParameters[KeyExtraParameters] = extraParametersT; - + // Gets the app url NSURL *appURL = nil; NSString *appURLString = [actionWithClientParameters string:KeyLinkAwayAppURL]; if (appURLString.length > 0) { appURL = [NSURL URLWithString:appURLString]; } - + // Gets the browser url NSURL *otherURL = nil; NSString *otherURLString = [actionWithClientParameters string:KeyLinkAwayURL]; if (otherURLString.length > 0) { otherURL = [NSURL URLWithString:otherURLString]; } - + // Provide the URL and App URL to be modified if needed by a subclass or delegate. [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionWithClientParameters additionalData:additionalData delegateObject:delegateObject]; }; - + [self getClientParameter:[actionInformation dict:KeyClientParameters] requestParameters:nil showLoadingOverlay:true @@ -437,13 +457,13 @@ NSString * const KeyActionTypeOpen = @"openPage"; } + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - + NSDictionary *clientParamters = [actionInformation dict:KeyClientParameters]; if (clientParamters) { [[MVMCoreActionHandler sharedActionHandler] getClientParameter:clientParamters - requestParameters: requestParameters.parameters - showLoadingOverlay: !requestParameters.backgroundRequest - completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { + requestParameters: requestParameters.parameters + showLoadingOverlay: !requestParameters.backgroundRequest + completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { [requestParameters addRequestParameters:jsonDictionary]; [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject]; }]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index 907feed..f9746bc 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -26,6 +26,9 @@ extern NSString * const KeyButtonMap; extern NSString * const KeyOpenSupport; extern NSString * const KeyPostAction; +extern NSString * const KeyAdd; +extern NSString * const KeyCreate; + extern NSString * const KeyLinks; extern NSString * const KeyTitle; extern NSString * const KeyMessage; @@ -35,6 +38,7 @@ extern NSString * const KeyActionTypeShare; extern NSString * const KeyShareType; extern NSString * const KeyShareText; extern NSString * const KeyActionTypeSMS; +extern NSString * const KeyActionTypeContact; extern NSString * const KeyActionTypeCall; extern NSString * const KeyActionTypePreviousSubmit; extern NSString * const KeyActionTypeCancel; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index a678877..8f572f7 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -28,6 +28,9 @@ NSString * const KeyButtonMap = @"ButtonMap"; NSString * const KeyOpenSupport = @"openSupport"; NSString * const KeyPostAction = @"PostAction"; +NSString * const KeyAdd = @"add"; +NSString * const KeyCreate = @"create"; + NSString * const KeyLinks = @"Links"; NSString * const KeyTitle = @"title"; NSString * const KeyMessage = @"message"; @@ -36,6 +39,7 @@ NSString * const KeyActionTypeBack = @"back"; NSString * const KeyActionTypeShare = @"share"; NSString * const KeyActionTypeCall = @"call"; NSString * const KeyActionTypeSMS = @"sms"; +NSString * const KeyActionTypeContact = @"contact"; NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift index d2f10d4..1c9bbd4 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift @@ -15,8 +15,8 @@ public static var identifier: String = "contact" public var actionType: String = ActionCallModel.identifier // TODO: decode into phone number once action handler is re-written - public var callNumber: String - public var message: String? +// public var callNumber: String + public var approach: String = KeyCreate public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -25,8 +25,8 @@ //-------------------------------------------------- public init(callNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { - self.callNumber = callNumber - self.message = message +// self.callNumber = callNumber +// self.message = message self.extraParameters = extraParameters self.analyticsData = analyticsData } diff --git a/MVMCore/MVMCore/Models/Model/ModelProtocol.swift b/MVMCore/MVMCore/Models/Model/ModelProtocol.swift index a7adfcb..960f593 100644 --- a/MVMCore/MVMCore/Models/Model/ModelProtocol.swift +++ b/MVMCore/MVMCore/Models/Model/ModelProtocol.swift @@ -35,11 +35,11 @@ public protocol ModelProtocol: Codable { extension ModelProtocol { static public func decode(keyedContainer: KeyedDecodingContainer, codingKey: K) throws -> Self? { - return try keyedContainer.decodeIfPresent(self, forKey: codingKey) + try keyedContainer.decodeIfPresent(self, forKey: codingKey) } static public func decode(unkeyedContainer: inout UnkeyedDecodingContainer) throws -> Self? { - return try unkeyedContainer.decodeIfPresent(self) + try unkeyedContainer.decodeIfPresent(self) } public func encode(keyedContainer: inout KeyedEncodingContainer, codingKey: K) throws { @@ -50,4 +50,3 @@ extension ModelProtocol { try unkeyedContainer.encode(self) } } - From 2a8d24836635a2845d231c5e42e38e46d3b7e32d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 31 Mar 2021 14:00:11 -0400 Subject: [PATCH 099/150] unify the mappings --- .../Client Parameters/ClientParameterHandler.swift | 11 +++++++++-- MVMCore/MVMCore/Models/Model/ModelRegistry.swift | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift index dc34e8e..d40534b 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -13,8 +13,15 @@ let group = DispatchGroup() open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { - guard let parameterType = ModelRegistry.getHandler(clientParameterModel) as? ClientParameterProtocol.Type else { return nil } - return parameterType.init(clientParameterModel) + do { + let parameterType = try ModelRegistry.getHandler(clientParameterModel) as! ClientParameterProtocol.Type + return parameterType.init(clientParameterModel) + } catch { + if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: #function) { + MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject) + } + return nil + } } func getClientParameterModel(_ clientParameters: [String: Any]) throws -> ClientParameterModel? { diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index b36edf3..097868e 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -18,6 +18,7 @@ public struct ModelRegistry { case decoderErrorObjectNotPresent(codingKey: CodingKey, codingPath: [CodingKey]) case decoderErrorModelNotMapped(identifer: String? = nil, codingKey: CodingKey? = nil, codingPath: [CodingKey]? = nil) case other(message: String) + case handlerNotMapped(identifer: String? = nil, categoryName: String? = nil) } private struct Category { @@ -62,15 +63,20 @@ public struct ModelRegistry { categories[M.categoryName] = category } - public static func getHandler(_ model: ModelProtocol) -> ModelHandlerProtocol.Type? { + public static func getHandler(_ model: ModelProtocol) throws -> ModelHandlerProtocol.Type { //get the modelType let modelType = type(of: model) //get the category for the ModelProtocol - guard let category = categories[modelType.categoryName] else { return nil } + guard let category = categories[modelType.categoryName] else { + throw ModelRegistry.Error.other(message: "Category not found: \(modelType.categoryName)") + } //get the containerProtocol for this ModelProtocol you had registered - return category.handlerTypes[modelType.identifier] + guard let handlerType = category.handlerTypes[modelType.identifier] else { + throw ModelRegistry.Error.handlerNotMapped(identifer: modelType.identifier, categoryName: category.name) + } + return handlerType } private static func getCategory(for type: M.Type) -> Category { From 2d1b3dbf5415c6a47e85d4e847ee27c546ef5a1c Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 31 Mar 2021 14:33:31 -0400 Subject: [PATCH 100/150] re-org actions in core --- MVMCore/MVMCore/Models/ModelMapping.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index a50ee54..5b69b46 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -8,7 +8,9 @@ @objcMembers open class ModelMapping: NSObject { - open class func registerObjects() { + open class func registerObjects() {} + + open class func registerActions() { try? ModelRegistry.register(ActionOpenPageModel.self) try? ModelRegistry.register(ActionOpenUrlModel.self) try? ModelRegistry.register(ActionCallModel.self) From d9aa011f051075be4e98b7fe066dc4babde74082 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 6 Apr 2021 14:43:50 -0400 Subject: [PATCH 101/150] undo --- .../MVMCore/ActionHandling/MVMCoreActionHandler.m | 14 -------------- MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m | 1 - 2 files changed, 15 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 9696494..09a15f2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -69,9 +69,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeCall]) { [self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else if ([actionType isEqualToString:KeyActionTypeSMS]) { - [self smsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else if ([actionType isEqualToString:KeyActionTypeContact]) { [self contactAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -259,17 +256,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -/// Send Text Message -- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - NSString *phoneNumber = [actionInformation stringForKey:KeyCallNumber]; - NSString *message = [actionInformation stringForKey:KeyMessage]; - NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; - // NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; -} - - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { NSString *approach = [actionInformation stringForKey:@"approach"]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 8f572f7..edad8da 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -38,7 +38,6 @@ NSString * const KeyActionTypeRestart = @"restart"; NSString * const KeyActionTypeBack = @"back"; NSString * const KeyActionTypeShare = @"share"; NSString * const KeyActionTypeCall = @"call"; -NSString * const KeyActionTypeSMS = @"sms"; NSString * const KeyActionTypeContact = @"contact"; NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; NSString * const KeyActionTypeCancel = @"cancel"; From f272cd580b1999cb9a1d15be5aa6ad33325811b0 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 6 Apr 2021 15:21:09 -0400 Subject: [PATCH 102/150] rename and update --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 8 ++-- .../ActionHandling/MVMCoreActionHandler.h | 3 +- .../ActionHandling/MVMCoreActionHandler.m | 45 ++++++++++++++++--- ...ctModel.swift => ActionContactModel.swift} | 17 ++++--- MVMCore/MVMCore/Models/ModelMapping.swift | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) rename MVMCore/MVMCore/Models/ActionType/{ActionMakeContactModel.swift => ActionContactModel.swift} (63%) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index cc098b9..97a9bb3 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -34,7 +34,7 @@ 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; - 0ACC81A22613C73800A9C886 /* ActionMakeContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */; }; + 0ACC81A22613C73800A9C886 /* ActionContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ACC81A12613C73800A9C886 /* ActionContactModel.swift */; }; 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; 30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -170,7 +170,7 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; - 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionMakeContactModel.swift; sourceTree = ""; }; + 0ACC81A12613C73800A9C886 /* ActionContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionContactModel.swift; sourceTree = ""; }; 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; @@ -454,7 +454,7 @@ BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, - 0ACC81A12613C73800A9C886 /* ActionMakeContactModel.swift */, + 0ACC81A12613C73800A9C886 /* ActionContactModel.swift */, ); path = ActionType; sourceTree = ""; @@ -856,7 +856,7 @@ 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, - 0ACC81A22613C73800A9C886 /* ActionMakeContactModel.swift in Sources */, + 0ACC81A22613C73800A9C886 /* ActionContactModel.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 1dc2aa5..0d15a0b 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -11,13 +11,14 @@ #import #import #import +#import @class DelegateObject; extern NSString * _Nonnull const KeyActionType; extern NSString * _Nonnull const KeyActionTypeLinkAway; extern NSString * _Nonnull const KeyActionTypeOpen; -@interface MVMCoreActionHandler : NSObject +@interface MVMCoreActionHandler : NSObject /// Returns the shared action handler + (nullable instancetype)sharedActionHandler; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 09a15f2..3915d14 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -27,6 +27,7 @@ #import #import #import "MVMCoreLoadingOverlayHandler.h" +#import NSString * const KeyActionType = @"actionType"; NSString * const KeyActionTypeLinkAway = @"openURL"; @@ -258,21 +259,55 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + __weak typeof(self) weakSelf = self; NSString *approach = [actionInformation stringForKey:@"approach"]; + NSString *MDN = [actionInformation string:KeyCallNumber]; if ([approach isEqualToString:KeyAdd]) { } else if ([approach isEqualToString:KeyCreate]) { + NSString *firstName = [actionInformation string:@"firstName"]; + NSString *lastname = [actionInformation string:@"lastName"]; + } -// NSString *message = [actionInformation stringForKey:KeyMessage]; -// NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; - // NSURL *url = [NSURL URLWithString:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; -// [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; + CNContactStore *store = [[CNContactStore alloc] init]; + CNMutableContact *mutContact = [[CNMutableContact alloc] init]; + + CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelHome value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; + mutContact.phoneNumbers = @[phone]; + + CNContactViewController *controller = [[CNContactViewController alloc] init]; + controller.contactStore = store; + controller.delegate = weakSelf; + + + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; + }]; } +- (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(CNContact *)contact { + + [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; +} + +- (BOOL)contactViewController:(CNContactViewController *)viewController shouldPerformDefaultActionForContactProperty:(CNContactProperty *)property { + return YES; +} +/* + let store = CNContactStore() + let contact = CNMutableContact() + let homePhone = CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue :phNo )) + contact.phoneNumbers = [homePhone] + let controller = CNContactViewController(forUnknownContact : contact) + controller.contactStore = store + controller.delegate = self + self.navigationController?.setNavigationBarHidden(false, animated: true) + self.navigationController!.pushViewController(controller, animated: true) + */ + - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Call NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift similarity index 63% rename from MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift rename to MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index 1c9bbd4..19aa3c1 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionMakeContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -1,5 +1,5 @@ // -// ActionMakeContactModel.swift +// ActionContactModel.swift // MVMCore // // Created by Kevin Christiano on 3/30/21. @@ -7,7 +7,7 @@ // -@objcMembers public class ActionMakeContactModel: ActionModelProtocol { +@objcMembers public class ActionContactModel: ActionModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -15,18 +15,21 @@ public static var identifier: String = "contact" public var actionType: String = ActionCallModel.identifier // TODO: decode into phone number once action handler is re-written -// public var callNumber: String + public var callNumber: String + public var firstName: String? + public var lastName: String? public var approach: String = KeyCreate public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(callNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { -// self.callNumber = callNumber -// self.message = message + public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.callNumber = callNumber + self.firstName = firstName + self.lastName = lastName self.extraParameters = extraParameters self.analyticsData = analyticsData } diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 660a534..26cb696 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -23,7 +23,7 @@ try? ModelRegistry.register(ActionNoopModel.self) try? ModelRegistry.register(ActionActionsModel.self) try? ModelRegistry.register(ActionOpenSMSModel.self) - try? ModelRegistry.register(ActionMakeContactModel.self) + try? ModelRegistry.register(ActionContactModel.self) } } From dcc8567401ded41f04f0100d119201cf64dae9ff Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 10:22:30 -0400 Subject: [PATCH 103/150] latest contact --- .../ActionHandling/MVMCoreActionHandler.h | 2 +- .../ActionHandling/MVMCoreActionHandler.m | 109 +++++++++++------- .../ActionType/ActionContactModel.swift | 53 ++++++++- 3 files changed, 119 insertions(+), 45 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 0d15a0b..ff9471d 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -18,7 +18,7 @@ extern NSString * _Nonnull const KeyActionType; extern NSString * _Nonnull const KeyActionTypeLinkAway; extern NSString * _Nonnull const KeyActionTypeOpen; -@interface MVMCoreActionHandler : NSObject +@interface MVMCoreActionHandler : NSObject /// Returns the shared action handler + (nullable instancetype)sharedActionHandler; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 3915d14..1165aec 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -257,57 +257,45 @@ 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 *approach = [actionInformation stringForKey:@"approach"]; - NSString *MDN = [actionInformation string:KeyCallNumber]; - - if ([approach isEqualToString:KeyAdd]) { - - } else if ([approach isEqualToString:KeyCreate]) { - - NSString *firstName = [actionInformation string:@"firstName"]; - NSString *lastname = [actionInformation string:@"lastName"]; - - } - CNContactStore *store = [[CNContactStore alloc] init]; CNMutableContact *mutContact = [[CNMutableContact alloc] init]; - CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelHome value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; + NSString *MDN = [actionInformation string:KeyCallNumber]; + NSString *approach = [actionInformation stringForKey:@"approach"]; + + CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; mutContact.phoneNumbers = @[phone]; - CNContactViewController *controller = [[CNContactViewController alloc] init]; - controller.contactStore = store; - controller.delegate = weakSelf; - - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; - }]; + if ([approach isEqualToString:KeyAdd]) { + // Nothing for now. + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init]; + controller.delegate = weakSelf; + + + [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; + }]; + + } else if ([approach isEqualToString:KeyCreate]) { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CNContactViewController *controller = [[CNContactViewController alloc] init]; + controller.contactStore = store; + controller.delegate = weakSelf; + + mutContact.givenName = [actionInformation string:@"firstName"]; + mutContact.familyName = [actionInformation string:@"lastName"]; + + [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; + }]; + } } -- (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(CNContact *)contact { - - [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; -} - -- (BOOL)contactViewController:(CNContactViewController *)viewController shouldPerformDefaultActionForContactProperty:(CNContactProperty *)property { - return YES; -} -/* - let store = CNContactStore() - let contact = CNMutableContact() - let homePhone = CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue :phNo )) - contact.phoneNumbers = [homePhone] - let controller = CNContactViewController(forUnknownContact : contact) - controller.contactStore = store - controller.delegate = self - self.navigationController?.setNavigationBarHidden(false, animated: true) - self.navigationController!.pushViewController(controller, animated: true) - */ - - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Call NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; @@ -385,6 +373,43 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } +#pragma mark - CNContactViewControllerDelegate + +- (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(CNContact *)contact { + + [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; +} + +- (BOOL)contactViewController:(CNContactViewController *)viewController shouldPerformDefaultActionForContactProperty:(CNContactProperty *)property { + return YES; +} + +#pragma mark - CNContactPickerDelegate + +- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker { + [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; +} + +- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact { + + CNContactStore *store = [[CNContactStore alloc] init]; + CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; + CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:@"1234567890"]; + CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelPhoneNumberMobile value:number]; + NSMutableArray *phoneNumbers = [NSMutableArray new]; + [phoneNumbers addObject:labelValue]; + [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; + existingContact.phoneNumbers = phoneNumbers; + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; + + controller.contactStore = store; + controller.delegate = self; + + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; + }]; +} + #pragma mark - open url functions - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { diff --git a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index 19aa3c1..e5f1b38 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -6,8 +6,10 @@ // Copyright © 2021 myverizon. All rights reserved. // +import ContactsUI -@objcMembers public class ActionContactModel: ActionModelProtocol { + +@objcMembers public class ActionContactModel: ActionModelProtocol {//NSObject, ActionModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -26,11 +28,58 @@ // MARK: - Initializer //-------------------------------------------------- - public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { self.callNumber = callNumber self.firstName = firstName self.lastName = lastName + self.approach = approach self.extraParameters = extraParameters self.analyticsData = analyticsData } } + +// MARK: - CNContactViewControllerDelegate +//extension ActionContactModel: CNContactViewControllerDelegate { +// +// public func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { +// +// MVMCoreNavigationHandler.shared()?.removeCurrentViewController() +// } +// +// public func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool { +// true +// } +//} +/* +// MARK: - CNContactPickerDelegate +extension ActionContactModel: CNContactPickerDelegate { + + func contactPickerDidCancel(_ picker: CNContactPickerViewController) { + MVMCoreNavigationHandler.shared().removeCurrentViewController() + } + + func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) { + + let store = CNContactStore() + let existingContact = contact as? CNMutableContact + let number = CNPhoneNumber(stringValue: "1234567890") + let labelValue = CNLabeledValue(label: CNLabelPhoneNumberMobile, value: number) + var phoneNumbers: [CNLabeledValue]? = [] + phoneNumbers?.append(labelValue) + if let phoneNumbers1 = existingContact?.phoneNumbers { + phoneNumbers?.append(contentsOf: phoneNumbers1) + } + if let phoneNumbers = phoneNumbers { + existingContact?.phoneNumbers = phoneNumbers + } + let controller = CNContactViewController(forNewContact: existingContact) + + controller.contactStore = store + controller.delegate = self + + MVMCoreDispatchUtility.performBlock(onMainThread: { + MVMCoreNavigationHandler.shared().present(controller, animated: true) + }) + } +} +*/ From f5613644a0079400eb3610e12e9b2b689884e7de Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 11:41:49 -0400 Subject: [PATCH 104/150] create is working now. --- .../ActionHandling/MVMCoreActionHandler.m | 65 ++++++++++--------- .../ActionType/ActionContactModel.swift | 48 +------------- 2 files changed, 35 insertions(+), 78 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 1165aec..a09eb6a 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -263,36 +263,40 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { __weak typeof(self) weakSelf = self; - CNContactStore *store = [[CNContactStore alloc] init]; - CNMutableContact *mutContact = [[CNMutableContact alloc] init]; NSString *MDN = [actionInformation string:KeyCallNumber]; - NSString *approach = [actionInformation stringForKey:@"approach"]; - CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; - mutContact.phoneNumbers = @[phone]; - - if ([approach isEqualToString:KeyAdd]) { - // Nothing for now. - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init]; - controller.delegate = weakSelf; - - - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; - }]; + if (MDN) { + CNMutableContact *contact = [[CNMutableContact alloc] init]; + NSString *approach = [actionInformation stringForKey:@"approach"]; - } else if ([approach isEqualToString:KeyCreate]) { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - CNContactViewController *controller = [[CNContactViewController alloc] init]; - controller.contactStore = store; - controller.delegate = weakSelf; - - mutContact.givenName = [actionInformation string:@"firstName"]; - mutContact.familyName = [actionInformation string:@"lastName"]; - - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; - }]; + CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; + contact.phoneNumbers = @[phone]; + + if ([approach isEqualToString:KeyAdd]) { + // Nothing for now. + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init]; + 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]; + }]; + } } } @@ -376,7 +380,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; #pragma mark - CNContactViewControllerDelegate - (void)contactViewController:(CNContactViewController *)viewController didCompleteWithContact:(CNContact *)contact { - [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; } @@ -395,13 +398,13 @@ NSString * const KeyActionTypeOpen = @"openPage"; CNContactStore *store = [[CNContactStore alloc] init]; CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:@"1234567890"]; - CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelPhoneNumberMobile value:number]; + CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; NSMutableArray *phoneNumbers = [NSMutableArray new]; [phoneNumbers addObject:labelValue]; [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; existingContact.phoneNumbers = phoneNumbers; - CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; controller.contactStore = store; controller.delegate = self; @@ -410,7 +413,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; } -#pragma mark - open url functions +#pragma mark - Open URL - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -496,7 +499,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; } -#pragma mark - Default Action Protocol Functions +#pragma mark - Default Action Protocol + (void)defaultLogAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject{ // Currently no default log action but this will eventually be server driven. diff --git a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index e5f1b38..1fee221 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -9,7 +9,7 @@ import ContactsUI -@objcMembers public class ActionContactModel: ActionModelProtocol {//NSObject, ActionModelProtocol { +@objcMembers public class ActionContactModel: ActionModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -37,49 +37,3 @@ import ContactsUI self.analyticsData = analyticsData } } - -// MARK: - CNContactViewControllerDelegate -//extension ActionContactModel: CNContactViewControllerDelegate { -// -// public func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { -// -// MVMCoreNavigationHandler.shared()?.removeCurrentViewController() -// } -// -// public func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool { -// true -// } -//} -/* -// MARK: - CNContactPickerDelegate -extension ActionContactModel: CNContactPickerDelegate { - - func contactPickerDidCancel(_ picker: CNContactPickerViewController) { - MVMCoreNavigationHandler.shared().removeCurrentViewController() - } - - func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) { - - let store = CNContactStore() - let existingContact = contact as? CNMutableContact - let number = CNPhoneNumber(stringValue: "1234567890") - let labelValue = CNLabeledValue(label: CNLabelPhoneNumberMobile, value: number) - var phoneNumbers: [CNLabeledValue]? = [] - phoneNumbers?.append(labelValue) - if let phoneNumbers1 = existingContact?.phoneNumbers { - phoneNumbers?.append(contentsOf: phoneNumbers1) - } - if let phoneNumbers = phoneNumbers { - existingContact?.phoneNumbers = phoneNumbers - } - let controller = CNContactViewController(forNewContact: existingContact) - - controller.contactStore = store - controller.delegate = self - - MVMCoreDispatchUtility.performBlock(onMainThread: { - MVMCoreNavigationHandler.shared().present(controller, animated: true) - }) - } -} -*/ From 4686dc82568729d1bb14b9395e35b6de38493b30 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 14:15:12 -0400 Subject: [PATCH 105/150] contact behavior --- .../ActionHandling/MVMCoreActionHandler.m | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index a09eb6a..39d43ca 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -274,9 +274,10 @@ NSString * const KeyActionTypeOpen = @"openPage"; contact.phoneNumbers = @[phone]; if ([approach isEqualToString:KeyAdd]) { - // Nothing for now. [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]; @@ -395,22 +396,27 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact { - CNContactStore *store = [[CNContactStore alloc] init]; - CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; - CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:@"1234567890"]; - CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; - NSMutableArray *phoneNumbers = [NSMutableArray new]; - [phoneNumbers addObject:labelValue]; - [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; - existingContact.phoneNumbers = phoneNumbers; + // This is a means to pass the data to this delegate function. + NSString *MDN = picker.accessibilityValue; - CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; - controller.contactStore = store; - controller.delegate = self; - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; - }]; + if (MDN) { + CNContactStore *store = [[CNContactStore alloc] init]; + CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; + CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:MDN]; + CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; + NSMutableArray *phoneNumbers = [NSMutableArray new]; + [phoneNumbers addObject:labelValue]; + [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; + existingContact.phoneNumbers = phoneNumbers; + + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; + controller.contactStore = store; + controller.delegate = self; + + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; + }]; + } } #pragma mark - Open URL From c3601741c8cda29f4b3b1a6550eb17b74a1a41d5 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 14:24:30 -0400 Subject: [PATCH 106/150] undo --- .../Utility/HardCodedServerResponse/MFHardCodedServerResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index efa33b6..eb9fba9 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,7 +9,7 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG +#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG #if ENABLE_HARD_CODED_RESPONSE From dc90af50b2a4f3e1d62fbcdb1555ee983c32663c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 15:37:40 -0400 Subject: [PATCH 107/150] for reference. --- .../ActionHandling/MVMCoreActionHandler.m | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 39d43ca..7248264 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -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 { From a25e88427a9bb1b8fc2318f2771ae95d1b51a99c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 7 Apr 2021 16:11:18 -0400 Subject: [PATCH 108/150] contact action --- .../ActionHandling/MVMCoreActionHandler.m | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 7248264..7c15527 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -257,50 +257,45 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -// Privacy - Contacts Usage Description - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { -// CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts]; -// -// if (status == CNAuthorizationStatusAuthorized) { - __weak typeof(self) weakSelf = self; + __weak typeof(self) weakSelf = self; + + NSString *MDN = [actionInformation string:KeyCallNumber]; + + if (MDN) { + CNMutableContact *contact = [[CNMutableContact alloc] init]; + NSString *approach = [actionInformation stringForKey:@"approach"]; - NSString *MDN = [actionInformation string:KeyCallNumber]; + CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:MDN]]; + contact.phoneNumbers = @[phone]; - 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]; - }]; - } + 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 { From 9003e9a8d5f54a1f02720803f5f58ab845c2d8d5 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Fri, 9 Apr 2021 10:43:37 -0400 Subject: [PATCH 109/150] Sms action --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ++ .../ActionHandling/MVMCoreActionHandler.h | 3 + .../ActionHandling/MVMCoreActionHandler.m | 69 +++++++++++-------- .../MVMCore/Constants/MVMCoreJSONConstants.h | 2 + .../MVMCore/Constants/MVMCoreJSONConstants.m | 2 + .../ActionType/ActionOpenSMSModel.swift | 33 +++++++++ .../MVMCore/Models/Model/ModelProtocol.swift | 5 +- MVMCore/MVMCore/Models/ModelMapping.swift | 2 + 8 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index ed82363..33451d0 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; + 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; 30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; }; @@ -168,6 +169,7 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionTimeHandler.m; sourceTree = ""; }; @@ -449,6 +451,7 @@ 94C014D824212360005811A9 /* ActionSettingModel.swift */, BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, ); path = ActionType; sourceTree = ""; @@ -889,6 +892,7 @@ 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */, D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */, AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, + 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */, 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */, 8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */, D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index d46fa63..1dc2aa5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -50,6 +50,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; /// Goes back - (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +/// Opens Text Message +- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + /// Makes a phone call - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index b534d2a..e6183cf 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -69,9 +69,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeCall]) { [self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } else if ([actionType isEqualToString:KeyActionTypeSMS]) { + [self smsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + } else if ([actionType isEqualToString:KeyActionTypeShare]) { [self shareAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - + } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { [self previousSubmitAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -83,7 +86,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSettings]) { [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - + } else if ([actionType isEqualToString:KeyActionTypeNoop]) { } else if ([actionType isEqualToString:KeyActionTypeActions]) { [self actions:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -99,7 +102,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; completionHandler(nil); return; } - + if (showLoadingOverlay) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading]; } @@ -112,22 +115,22 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSError *error = nil; [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"]; - + ClientParameterHandler *clientParameterHandler = [[ClientParameterHandler alloc] init]; [clientParameterHandler getParametersWith:clientParametersMap - requestParameters:requestParameters - error:&error - completionHandler:^(NSDictionary * _Nullable clientParameters) { - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; - if (clientParameters) { - stopLoadingOverlay(); - completionHandler(clientParameters); - } else { - [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; - stopLoadingOverlay(); - completionHandler(nil); - } - }]; + requestParameters:requestParameters + error:&error + completionHandler:^(NSDictionary * _Nullable clientParameters) { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"]; + if (clientParameters) { + stopLoadingOverlay(); + completionHandler(clientParameters); + } else { + [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client parameters"]; + stopLoadingOverlay(); + completionHandler(nil); + } + }]; if (error) { stopLoadingOverlay(); @@ -155,14 +158,14 @@ NSString * const KeyActionTypeOpen = @"openPage"; // Loads the given page type. NSString *pageType = [actionInformation stringForKey:KeyPageType]; - + if (pageType.length == 0) { // No page type to load, show error. MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeOpen]]; [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; return; } - + MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation]; [self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { @@ -253,6 +256,14 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } +- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + + NSString *phoneNumber = [actionInformation stringForKey:@"phoneNumber"]; + NSString *message = [actionInformation stringForKey:KeyMessage]; + NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message]; + [MVMCoreActionUtility linkAway:[smsQuery stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] appURLString:nil]; +} + - (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Call NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; @@ -333,33 +344,33 @@ NSString * const KeyActionTypeOpen = @"openPage"; #pragma mark - open url functions - (void)linkAwayAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - + __weak typeof(self) weakSelf = self; void (^performAction)(NSDictionary*) = ^(NSDictionary* extraParamters) { - + NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy]; NSMutableDictionary *extraParametersT = [extraParamters mutableCopy]; [extraParametersT addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]]; actionWithClientParameters[KeyExtraParameters] = extraParametersT; - + // Gets the app url NSURL *appURL = nil; NSString *appURLString = [actionWithClientParameters string:KeyLinkAwayAppURL]; if (appURLString.length > 0) { appURL = [NSURL URLWithString:appURLString]; } - + // Gets the browser url NSURL *otherURL = nil; NSString *otherURLString = [actionWithClientParameters string:KeyLinkAwayURL]; if (otherURLString.length > 0) { otherURL = [NSURL URLWithString:otherURLString]; } - + // Provide the URL and App URL to be modified if needed by a subclass or delegate. [weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionWithClientParameters additionalData:additionalData delegateObject:delegateObject]; }; - + [self getClientParameter:[actionInformation dict:KeyClientParameters] requestParameters:nil showLoadingOverlay:true @@ -423,13 +434,13 @@ NSString * const KeyActionTypeOpen = @"openPage"; } + (void)defaultHandleOpenPageForRequestParameters:(nonnull MVMCoreRequestParameters *)requestParameters actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - + NSDictionary *clientParamters = [actionInformation dict:KeyClientParameters]; if (clientParamters) { [[MVMCoreActionHandler sharedActionHandler] getClientParameter:clientParamters - requestParameters: requestParameters.parameters - showLoadingOverlay: !requestParameters.backgroundRequest - completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { + requestParameters: requestParameters.parameters + showLoadingOverlay: !requestParameters.backgroundRequest + completionHandler: ^(NSDictionary * _Nullable jsonDictionary) { [requestParameters addRequestParameters:jsonDictionary]; [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject]; }]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index c2d7f8e..00a72f1 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -34,6 +34,7 @@ extern NSString * const KeyActionTypeBack; extern NSString * const KeyActionTypeShare; extern NSString * const KeyShareType; extern NSString * const KeyShareText; +extern NSString * const KeyActionTypeSMS; extern NSString * const KeyActionTypeCall; extern NSString * const KeyActionTypePreviousSubmit; extern NSString * const KeyActionTypeCancel; @@ -45,6 +46,7 @@ extern NSString * const KeyActionInformation; extern NSString * const KeyLinkAwayAppURL; extern NSString * const KeyLinkAwayURL; extern NSString * const KeyCallNumber; +extern NSString * const KeyPhoneNumber; extern NSString * const KeyPresentationStyle; extern NSString * const KeyExtraParameters; extern NSString * const KeyContextRoot; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 80317ea..71ecd0e 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -35,6 +35,7 @@ NSString * const KeyActionTypeRestart = @"restart"; NSString * const KeyActionTypeBack = @"back"; NSString * const KeyActionTypeShare = @"share"; NSString * const KeyActionTypeCall = @"call"; +NSString * const KeyActionTypeSMS = @"sms"; NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; @@ -45,6 +46,7 @@ NSString * const KeyActionInformation = @"actionInformation"; NSString * const KeyLinkAwayAppURL = @"appURL"; NSString * const KeyLinkAwayURL = @"browserUrl"; NSString * const KeyCallNumber = @"callNumber"; +NSString * const KeyPhoneNumber = @"phoneNumber"; NSString * const KeyPresentationStyle = @"presentationStyle"; NSString * const KeyExtraParameters = @"extraParameters"; NSString * const KeyContextRoot = @"appContext"; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift new file mode 100644 index 0000000..60ee1ba --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift @@ -0,0 +1,33 @@ +// +// ActionOpenSMSModel.swift +// MVMCore +// +// Created by Kevin Christiano on 3/11/21. +// Copyright © 2021 myverizon. All rights reserved. +// + + +@objcMembers public class ActionOpenSMSModel: ActionModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "sms" + public var actionType: String = ActionCallModel.identifier + + public var phoneNumber: String + public var message: String? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(phoneNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.phoneNumber = phoneNumber + self.message = message + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCore/MVMCore/Models/Model/ModelProtocol.swift b/MVMCore/MVMCore/Models/Model/ModelProtocol.swift index a7adfcb..960f593 100644 --- a/MVMCore/MVMCore/Models/Model/ModelProtocol.swift +++ b/MVMCore/MVMCore/Models/Model/ModelProtocol.swift @@ -35,11 +35,11 @@ public protocol ModelProtocol: Codable { extension ModelProtocol { static public func decode(keyedContainer: KeyedDecodingContainer, codingKey: K) throws -> Self? { - return try keyedContainer.decodeIfPresent(self, forKey: codingKey) + try keyedContainer.decodeIfPresent(self, forKey: codingKey) } static public func decode(unkeyedContainer: inout UnkeyedDecodingContainer) throws -> Self? { - return try unkeyedContainer.decodeIfPresent(self) + try unkeyedContainer.decodeIfPresent(self) } public func encode(keyedContainer: inout KeyedEncodingContainer, codingKey: K) throws { @@ -50,4 +50,3 @@ extension ModelProtocol { try unkeyedContainer.encode(self) } } - diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 5b69b46..5524380 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -22,5 +22,7 @@ try? ModelRegistry.register(ActionSettingModel.self) try? ModelRegistry.register(ActionNoopModel.self) try? ModelRegistry.register(ActionActionsModel.self) + try? ModelRegistry.register(ActionOpenSMSModel.self) } } + From 440068246904fdd25ba5948209e5567f62f58a5e Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 9 Apr 2021 14:28:05 -0400 Subject: [PATCH 110/150] space --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index e275baf..c490be2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -72,7 +72,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSMS]) { [self smsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - + } else if ([actionType isEqualToString:KeyActionTypeContact]) { [self contactAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; From 1d968bd2c17ade1e10bce683ecc7499793d300ff Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 9 Apr 2021 16:43:37 -0400 Subject: [PATCH 111/150] merging. molecule updates. --- .../ActionHandling/MVMCoreActionHandler.m | 102 +++++++++--------- .../ActionType/ActionContactModel.swift | 6 +- 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index c490be2..7fc063a 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -272,40 +272,39 @@ NSString * const KeyActionTypeOpen = @"openPage"; __weak typeof(self) weakSelf = self; - NSString *MDN = [actionInformation string:KeyCallNumber]; + NSString *phoneNumber = [actionInformation string:@"phoneNumber"]; - 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]; - }]; - } + if (!phoneNumber) { return; } + CNMutableContact *contact = [[CNMutableContact alloc] init]; + NSString *approach = [actionInformation stringForKey:@"approach"]; + + CNLabeledValue *phone = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:[[CNPhoneNumber alloc] initWithStringValue:phoneNumber]]; + 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:phoneNumber]; + 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]; + }]; } } @@ -405,26 +404,25 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact { // This is a means to pass the data to this delegate function. - NSString *MDN = picker.accessibilityValue; + NSString *phoneNumber = picker.accessibilityValue; - if (MDN) { - CNContactStore *store = [[CNContactStore alloc] init]; - CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; - CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:MDN]; - CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; - NSMutableArray *phoneNumbers = [NSMutableArray new]; - [phoneNumbers addObject:labelValue]; - [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; - existingContact.phoneNumbers = phoneNumbers; - - CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; - controller.contactStore = store; - controller.delegate = self; - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; - }]; - } + if (!phoneNumber) { return; } + CNContactStore *store = [[CNContactStore alloc] init]; + CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; + CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:phoneNumber]; + CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; + NSMutableArray *phoneNumbers = [NSMutableArray new]; + [phoneNumbers addObject:labelValue]; + [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; + existingContact.phoneNumbers = phoneNumbers; + + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; + controller.contactStore = store; + controller.delegate = self; + + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; + }]; } #pragma mark - Open URL diff --git a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index 1fee221..facfbef 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -17,7 +17,7 @@ import ContactsUI public static var identifier: String = "contact" public var actionType: String = ActionCallModel.identifier // 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 lastName: String? public var approach: String = KeyCreate @@ -28,8 +28,8 @@ import ContactsUI // MARK: - Initializer //-------------------------------------------------- - public init(callNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { - self.callNumber = callNumber + public init(phoneNumber: String, firstName: String? = nil, lastName: String? = nil, approach: String = KeyCreate, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.phoneNumber = phoneNumber self.firstName = firstName self.lastName = lastName self.approach = approach From 98ddd3331d7dd25b69b494968f77e81228787099 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 9 Apr 2021 16:53:35 -0400 Subject: [PATCH 112/150] Added new behavior. Moved protocols to folder. --- MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift index facfbef..6ccbc13 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionContactModel.swift @@ -16,7 +16,7 @@ import ContactsUI public static var identifier: String = "contact" public var actionType: String = ActionCallModel.identifier - // TODO: decode into phone number once action handler is re-written + public var phoneNumber: String public var firstName: String? public var lastName: String? From 4ba0e3adfb9b66784e07b9406bdd1b6de9c0def3 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 12 Apr 2021 11:04:45 -0400 Subject: [PATCH 113/150] comment. removing header import. --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index ff9471d..1dc2aa5 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -11,14 +11,13 @@ #import #import #import -#import @class DelegateObject; extern NSString * _Nonnull const KeyActionType; extern NSString * _Nonnull const KeyActionTypeLinkAway; extern NSString * _Nonnull const KeyActionTypeOpen; -@interface MVMCoreActionHandler : NSObject +@interface MVMCoreActionHandler : NSObject /// Returns the shared action handler + (nullable instancetype)sharedActionHandler; From e54a41481498e0f2d8319f93826221f9f4c0c945 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 12 Apr 2021 13:44:27 -0400 Subject: [PATCH 114/150] moved protocol. --- .../ActionHandling/MVMCoreActionHandler.m | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 7fc063a..15fab4e 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -33,8 +33,10 @@ NSString * const KeyActionType = @"actionType"; NSString * const KeyActionTypeLinkAway = @"openURL"; NSString * const KeyActionTypeOpen = @"openPage"; -@implementation MVMCoreActionHandler +@interface MVMCoreActionHandler() +@end +@implementation MVMCoreActionHandler + (nullable instancetype)sharedActionHandler { return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].actionHandler classToVerify:self]; } @@ -285,7 +287,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; [MVMCoreDispatchUtility performBlockOnMainThread:^{ CNContactPickerViewController *controller = [[CNContactPickerViewController alloc] init]; // Setting to accessibilityValue as a workaround to pass data via the delegate function. - [controller setAccessibilityValue:phoneNumber]; + [controller.view setAccessibilityIdentifier:phoneNumber]; controller.delegate = weakSelf; [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:controller animated:YES]; @@ -404,23 +406,25 @@ NSString * const KeyActionTypeOpen = @"openPage"; - (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact { // This is a means to pass the data to this delegate function. - NSString *phoneNumber = picker.accessibilityValue; + NSString *phoneNumber = picker.view.accessibilityIdentifier; if (!phoneNumber) { return; } CNContactStore *store = [[CNContactStore alloc] init]; - CNMutableContact *existingContact = [(CNMutableContact*)contact mutableCopy]; - CNPhoneNumber * number = [[CNPhoneNumber alloc] initWithStringValue:phoneNumber]; - CNLabeledValue * labelValue = [[CNLabeledValue alloc]initWithLabel:CNLabelOther value:number]; + CNMutableContact *existingContact = [(CNMutableContact *)contact mutableCopy]; + CNPhoneNumber *number = [[CNPhoneNumber alloc] initWithStringValue:phoneNumber]; + CNLabeledValue *labelValue = [[CNLabeledValue alloc] initWithLabel:CNLabelOther value:number]; NSMutableArray *phoneNumbers = [NSMutableArray new]; [phoneNumbers addObject:labelValue]; [phoneNumbers addObjectsFromArray:existingContact.phoneNumbers]; existingContact.phoneNumbers = phoneNumbers; - CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; - controller.contactStore = store; - controller.delegate = self; + __weak typeof(self) weakSelf = self; [MVMCoreDispatchUtility performBlockOnMainThread:^{ + CNContactViewController *controller = [CNContactViewController viewControllerForNewContact:existingContact]; + controller.contactStore = store; + controller.delegate = weakSelf; + [[MVMCoreNavigationHandler sharedNavigationHandler] pushViewController:controller animated:YES]; }]; } From 289c15f453a4e4b2dab93b958ad34cf6efb1d9ea Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Thu, 6 May 2021 14:01:51 -0400 Subject: [PATCH 115/150] ActionOpenPageProtocol --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ++++ .../Models/ActionType/ActionOpenPageModel.swift | 2 +- .../Models/ActionType/ActionOpenPageProtocol.swift | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 MVMCore/MVMCore/Models/ActionType/ActionOpenPageProtocol.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 97a9bb3..49f3911 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; }; + 01DB1F2B26444F7F000F1AF4 /* ActionOpenPageProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DB1F2A26444F7F000F1AF4 /* ActionOpenPageProtocol.swift */; }; 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; }; 01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */; }; 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */; }; @@ -162,6 +163,7 @@ 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; 01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = ""; }; + 01DB1F2A26444F7F000F1AF4 /* ActionOpenPageProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPageProtocol.swift; sourceTree = ""; }; 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = ""; }; 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelProtocol.swift; sourceTree = ""; }; 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlModel.swift; sourceTree = ""; }; @@ -443,6 +445,7 @@ 016FF6EC259A4E3E00F5E4AA /* Client Parameters */, 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */, 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, + 01DB1F2A26444F7F000F1AF4 /* ActionOpenPageProtocol.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, @@ -898,6 +901,7 @@ AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */, 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */, + 01DB1F2B26444F7F000F1AF4 /* ActionOpenPageProtocol.swift in Sources */, 8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */, D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */, 016FF6EE259A4E6300F5E4AA /* ClientParameterModelProtocol.swift in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index c811414..7842fb2 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -7,7 +7,7 @@ // -@objcMembers open class ActionOpenPageModel: ActionModelProtocol, ClientParameterActionProtocol { +@objcMembers open class ActionOpenPageModel: ActionModelProtocol, ActionOpenPageProtocol, ClientParameterActionProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageProtocol.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageProtocol.swift new file mode 100644 index 0000000..7ee3032 --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageProtocol.swift @@ -0,0 +1,14 @@ +// +// ActionOpenPageProtocol.swift +// MVMCore +// +// Created by Suresh, Kamlesh on 5/6/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +import Foundation + + +public protocol ActionOpenPageProtocol: ModelProtocol { + var pageType: String { get set } +} From eeae6a596c5d04f2dc36fa4762b18e9d63f6d57d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 09:50:41 -0400 Subject: [PATCH 116/150] test view controller page type --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 8 +++++++ MVMCore/MVMCore/MVMCore.h | 1 + .../MVMCoreViewManagerProtocol.h | 11 ++++++++++ ...eViewManagerViewControllerProtocolHelper.h | 22 +++++++++++++++++++ ...eViewManagerViewControllerProtocolHelper.m | 17 ++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.h create mode 100644 MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.m diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 49f3911..e50deca 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -143,6 +143,8 @@ AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFFCFA631FCCC0D600FD0730 /* MVMCoreLoadingOverlayHandler.m */; }; AFFCFA681FCCC0D700FD0730 /* MVMCoreLoadingViewControllerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFFCFA641FCCC0D600FD0730 /* MVMCoreLoadingViewControllerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */; }; + D268D82B26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = D268D82926700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D268D82C26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D268D82A26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m */; }; D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073B625BB45C4001C7246 /* ActionActionsModel.swift */; }; D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */; }; D27073D125BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */; }; @@ -286,6 +288,8 @@ AFFCFA631FCCC0D600FD0730 /* MVMCoreLoadingOverlayHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreLoadingOverlayHandler.m; sourceTree = ""; }; AFFCFA641FCCC0D600FD0730 /* MVMCoreLoadingViewControllerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadingViewControllerProtocol.h; sourceTree = ""; }; BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNoopModel.swift; sourceTree = ""; }; + D268D82926700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewManagerViewControllerProtocolHelper.h; sourceTree = ""; }; + D268D82A26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreViewManagerViewControllerProtocolHelper.m; sourceTree = ""; }; D27073B625BB45C4001C7246 /* ActionActionsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionActionsModel.swift; sourceTree = ""; }; D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionHandler+Extension.swift"; sourceTree = ""; }; D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionDelegateProtocol+Extension.swift"; sourceTree = ""; }; @@ -498,6 +502,8 @@ AF43A71A1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h */, AF43A71F1FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h */, AF1201812108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h */, + D268D82926700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h */, + D268D82A26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m */, AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */, AFEEE8181FCDDE6B00B5EDD0 /* MVMCoreLoggingDelegateProtocol.h */, AF43A7001FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h */, @@ -715,6 +721,7 @@ AF43A7011FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h in Headers */, AF43A5771FBA5B7C008E9347 /* MVMCoreJSONConstants.h in Headers */, AFBB96631FBA3A570008D868 /* MVMCoreLoadRequestOperation.h in Headers */, + D268D82B26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h in Headers */, 8876D5CE1FB50A9E00EB2E3D /* MVMCore.h in Headers */, AF43A57B1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.h in Headers */, AFBB96B81FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h in Headers */, @@ -899,6 +906,7 @@ 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */, D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */, AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, + D268D82C26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m in Sources */, 0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */, 016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */, 01DB1F2B26444F7F000F1AF4 /* ActionOpenPageProtocol.swift in Sources */, diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index c7fbd4a..7ef1d6e 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -74,6 +74,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import +#import #import #import diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h index b9ab523..94cf031 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h @@ -17,4 +17,15 @@ // Returns if the manage currently contains the page with the page type. - (BOOL)containsPageWithPageType:(nullable NSString *)pageType; +@optional + +/// Notifies the manager that the controller received new data. +- (void)newDataReceivedInViewController:(nonnull UIViewController *)viewController; + +/// Call on a manager when a view controller will be displayed. (Mostly called by other managers) +- (void)willDisplayViewController:(nonnull UIViewController *)viewController; + +/// Call on a manager when a controller is displayed. (Mostly called by other managers) +- (void)displayedViewController:(nonnull UIViewController *)viewController; + @end diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.h new file mode 100644 index 0000000..46ee89e --- /dev/null +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.h @@ -0,0 +1,22 @@ +// +// MVMCoreViewManagerViewControllerProtocolHelper.h +// MVMCore +// +// Created by Scott Pfeil on 6/8/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MVMCoreViewManagerViewControllerProtocolHelper : NSObject + +/// Set the manager on the view controller. This function is a helper for swift because of the objc protocol ++ (void)helpSetManager:(nonnull UIViewController *)manager viewController:(nullable UIViewController *)viewController; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.m b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.m new file mode 100644 index 0000000..56d0b4f --- /dev/null +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerViewControllerProtocolHelper.m @@ -0,0 +1,17 @@ +// +// MVMCoreViewManagerViewControllerProtocolHelper.m +// MVMCore +// +// Created by Scott Pfeil on 6/8/21. +// Copyright © 2021 myverizon. All rights reserved. +// + +#import "MVMCoreViewManagerViewControllerProtocolHelper.h" + +@implementation MVMCoreViewManagerViewControllerProtocolHelper + ++ (void)helpSetManager:(nonnull UIViewController *)manager viewController:(nullable UIViewController *)viewController { + viewController.manager = manager; +} + +@end From bedacbf1ecf36ab4d38a303223b04ac94eb8b577 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 11 Jun 2021 11:04:47 -0400 Subject: [PATCH 117/150] Managers handle navigation bar nullable --- MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h index 94cf031..4407a49 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h @@ -12,7 +12,7 @@ @protocol MVMCoreViewManagerProtocol // Return the current view controller showing -- (nonnull UIViewController *)getCurrentViewController; +- (nullable UIViewController *)getCurrentViewController; // Returns if the manage currently contains the page with the page type. - (BOOL)containsPageWithPageType:(nullable NSString *)pageType; From cd6f56a3fcf3db20dbb2531a58abfd5bfbe1c0be Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 23 Jun 2021 15:41:59 -0400 Subject: [PATCH 118/150] fat library build --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 49f3911..e5d91e7 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -818,7 +818,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${CONFIGURATION}-iphoneos/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; }; /* End PBXShellScriptBuildPhase section */ From 0812eba421d864b81c7fc3df752e706d79cb92e8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 12:49:15 -0400 Subject: [PATCH 119/150] add git ci file --- .gitlab-ci.yml | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..13f0557 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,92 @@ +stages: + - test + +test: + stage: test + script: + - echo "This job tests something" +#stages: +# # - test +# - build # generate the remote view framework +# - deploy # deploy the framework to Artifactory as a snapshot +# - tag # on manual confirmation, tag the repository +# - go live # move the snapshot binary on artifactory into live status +# +##run_unit_tests: +## stage: test +## script: +## - xcodebuild test -project ProjectName.xcodeproj -scheme SchemeName -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2' | xcpretty -s +## tags: +## - xcode_12 +# +#build_project: +# stage: build +# script: +# - xcodebuild build -workspace RemoteView.xcworkspace -scheme RemoteViewAggregate | xcpretty +# artifacts: +# paths: +# - RemoteViewFramework/** +# expire_in: 1 week +# only: +# - branches +# - develop +# tags: +# - xcode_12_2 +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# +#deploy_snapshot: +# stage: deploy +# script: +# - cd Scripts && ./upload_remote_view_frameworks.sh +# only: +# - branches +# - develop +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# +#promote_snapshot: +# stage: go live +# # Prevent artifacts from needing to re-download. Everything we need is in Artifactory. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - cd Scripts && ./promote_remote_view_frameworks.sh $framework_ver +# only: +# - tags +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# +#create_version_tag: +# stage: tag +# when: manual +# # Prevent artifacts from needing to re-download. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project and create a tag of the version. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - git tag -a "v${framework_ver}" -m "Version ${framework_ver} created by gitlab-ci Build" +# # Extract the git repo url to ssh version (git@gitlab.verizon.com) +# - ci_push_repo="git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git" +# - echo $ci_push_repo +# # Set the remote url for pushing assuming the gitlab runner has SSH access to the repo. +# - git remote set-url --push origin $ci_push_repo +# - git push origin "v${framework_ver}" +# only: +# - develop +# tags: +# - bash_shell From 04438d581b055f0e197d88eaf1bc8e970ef05f77 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 13:02:34 -0400 Subject: [PATCH 120/150] add git ci file --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 13f0557..2aa2d55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,9 @@ test: stage: test script: - echo "This job tests something" + tags: + - xcode_12_2 + #stages: # # - test # - build # generate the remote view framework From bcd4b8f51da46a6b8ce40b32fa013300f17231d5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 13:39:27 -0400 Subject: [PATCH 121/150] add git ci file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2aa2d55..1f3230b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ test: - echo "This job tests something" tags: - xcode_12_2 - +# #stages: # # - test # - build # generate the remote view framework From 3283e0fe9a02cf1d4da54225e6a725093ede7652 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 13:44:29 -0400 Subject: [PATCH 122/150] add git ci file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f3230b..2aa2d55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ test: - echo "This job tests something" tags: - xcode_12_2 -# + #stages: # # - test # - build # generate the remote view framework From cfab2674469b1fd7b5177834475d6918363bed58 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:09:22 -0400 Subject: [PATCH 123/150] add git ci file 1 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2aa2d55..1f3230b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ test: - echo "This job tests something" tags: - xcode_12_2 - +# #stages: # # - test # - build # generate the remote view framework From 9dd5176c77b3b08b31eaf3ff6425bdff9c4ee2ab Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:35:56 -0400 Subject: [PATCH 124/150] build and upload --- .gitlab-ci.yml | 36 ++++++++++ Scripts/upload_framework.sh | 89 ++++++++++++++++++++++++ Scripts/upload_remote_view_frameworks.sh | 26 +++++++ 3 files changed, 151 insertions(+) create mode 100644 Scripts/upload_framework.sh create mode 100644 Scripts/upload_remote_view_frameworks.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f3230b..6665929 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,7 @@ stages: - test + - build + - deploy test: stage: test @@ -7,6 +9,40 @@ test: - echo "This job tests something" tags: - xcode_12_2 + +build_project: + stage: build + script: + - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty + artifacts: + paths: + - RemoteViewFramework/** + expire_in: 1 week + only: + - branches + - feature/testing + tags: + - xcode_12_2 + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + +deploy_snapshot: + stage: deploy + script: + - cd Scripts && ./upload_remote_view_frameworks.sh + only: + - branches + - feature/testing + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory # #stages: # # - test diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh new file mode 100644 index 0000000..c1e5990 --- /dev/null +++ b/Scripts/upload_framework.sh @@ -0,0 +1,89 @@ +#!/bin/bash -e + +# upload_framework.sh +# RemoteView +# +# Uploads an iOS framework to Artificatory given the local path as the first argument and the remote project name in Verizon OneArtifactory for the second argument. +# +# An API key from Artifcatory is required in the api_key.private file before uploading. +# +# The script will replace [VER] in the provided remote path with the version found in the framework bundle. +# +# Created by Hedden, Kyle Matthew on 3/2/18. +# Copyright © 2018 Verizon. All rights reserved. + +URL=$1 +LOCALPATH=$2 +REMOTEPATH=$3 + +if [ -z $URL ]; then + echo "The artifactory instance url must be specified as the first argument!" + exit 1 +fi + +echo ">>> UPLOAD START <<<" +echo "Local path: ${LOCALPATH}" +echo "Remote path: ${REMOTEPATH}" + +LOCALBASE=$(basename "${LOCALPATH}") +LOCALDIR=$(dirname "${LOCALPATH}") + +# Grab the framework version from the bundled Info.plist. +FRAMEWORKVER=$(/usr/libexec/plistbuddy -c "Print :CFBundleShortVersionString" "${LOCALPATH}/Info.plist") +echo -e "\nFramework version: \t${FRAMEWORKVER}" + +# Replace the [VER] placeholders with the found version. +REMOTEPATH="${REMOTEPATH//\[VER\]/$FRAMEWORKVER}" +echo -e "Resolved path: \t\t${REMOTEPATH}" + +if [ -z $ARTIFACTORY_APIKEY ]; then + # Read the API key from a private file. + read -r APIKEY < "api_key.private" +else + APIKEY=$ARTIFACTORY_APIKEY +fi + +if [ -z $APIKEY ]; then + read -p "Artifactory API Key:" APIKEY + echo $APIKEY >> api_key.private +fi + +echo -e "API Key: \t\t${APIKEY}" + +# Zip the framework & DSYM for uploading. +pushd $LOCALDIR +echo -e "---------\nZipping: \t\t${LOCALBASE}.zip" +zip -r -X "${LOCALBASE}.zip" $LOCALBASE +# Generate framework's SHA-1 checksum. +CHECKSUM=$(shasum -a 1 "${LOCALBASE}.zip" | cut -d " " -f 1) +echo -e "SHA-1 Checksum: \t${CHECKSUM}" +if [ -e ${LOCALBASE}.dSYM ]; then +echo -e "---------\nZipping: \t\t${LOCALBASE}.dSYM.zip" +zip -r -X "${LOCALBASE}.dSYM.zip" $LOCALBASE.dSYM +# Generate its SHA-1 checksum for dsym. +DSYM_CHECKSUM=$(shasum -a 1 "${LOCALBASE}.dSYM.zip" | cut -d " " -f 1) +echo -e "SHA-1 Checksum: \t${DSYM_CHECKSUM}" +fi +popd +mv ${LOCALPATH}.zip . +if [ -e ${LOCALPATH}.dSYM.zip ]; then +mv ${LOCALPATH}.dSYM.zip . +fi + +# Upload framework to Artifactory. +echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.zip" +curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.zip" -T "${LOCALBASE}.zip" + +# Cleanup. +rm "${LOCALBASE}.zip" + +if [ -e ${LOCALBASE}.dSYM.zip ]; then +# Upload dsym Artifactory. +echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.dSYM.zip" +curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${DSYM_CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.dSYM.zip" -T "${LOCALBASE}.dSYM.zip" +# Cleanup dsym. +rm ${LOCALBASE}.dSYM.zip +fi + + +echo -e "\n\n<<< UPLOAD COMPLETE >>>\n\n" diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_remote_view_frameworks.sh new file mode 100644 index 0000000..c495882 --- /dev/null +++ b/Scripts/upload_remote_view_frameworks.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +# upload_remote_view_frameworks.sh +# +# Uploads all compiled framework flavors in RemoteViewFramework to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. +# +# Created by Hedden, Kyle Matthew on 3/2/18. +# + +FRAMEWORK_VERSION=$(cd ../MVMCore && agvtool vers -terse) +if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then + echo This version tag has already been committed! Aborting! + exit 1 +fi + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +#xcodebuild -workspace "../RemoteView.xcworkspace" -scheme "RemoteViewAggregate" + +# Remote View Versions + +./upload_framework.sh $ARTIFACTORY_URL "../MVMCore/build/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT From 1438a2fafe63933d07b746e76118c68d3c5695e7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:36:21 -0400 Subject: [PATCH 125/150] build --- .gitlab-ci.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6665929..d5c02b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - test - build - - deploy +# - deploy test: stage: test @@ -29,21 +29,21 @@ build_project: variables: ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -deploy_snapshot: - stage: deploy - script: - - cd Scripts && ./upload_remote_view_frameworks.sh - only: - - branches - - feature/testing - tags: - - bash_shell - environment: - name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory - variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -# +#deploy_snapshot: +# stage: deploy +# script: +# - cd Scripts && ./upload_remote_view_frameworks.sh +# only: +# - branches +# - feature/testing +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +## #stages: # # - test # - build # generate the remote view framework From f1feda6943d5e2eff81d6b89401fe320922ce41d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:39:07 -0400 Subject: [PATCH 126/150] build --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5c02b0..bd03a39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ build_project: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty artifacts: paths: - - RemoteViewFramework/** + - MVMCore/** expire_in: 1 week only: - branches From 5040ce61add863cf37e4cea2e868a3777e8e175a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:44:36 -0400 Subject: [PATCH 127/150] build --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd03a39..ca743b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ build_project: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty artifacts: paths: - - MVMCore/** + - */universal/** expire_in: 1 week only: - branches From 7172880d76067e00220bd122d7f6c9633cb49ef1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 14:45:31 -0400 Subject: [PATCH 128/150] build --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca743b4..8bb4709 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ build_project: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty artifacts: paths: - - */universal/** + - MVMCore/build/universal/** expire_in: 1 week only: - branches From 6045e959c674c2700bdf21369d8ee3d5ebcdd9d8 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:00:37 -0400 Subject: [PATCH 129/150] deploy --- .gitlab-ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8bb4709..b396cb6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - test - build -# - deploy + - deploy test: stage: test @@ -29,20 +29,20 @@ build_project: variables: ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -#deploy_snapshot: -# stage: deploy -# script: -# - cd Scripts && ./upload_remote_view_frameworks.sh -# only: -# - branches -# - feature/testing -# tags: -# - bash_shell -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +deploy_snapshot: + stage: deploy + script: + - cd Scripts && ./upload_remote_view_frameworks.sh + only: + - branches + - feature/testing + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory ## #stages: # # - test From 9b56fc2f0d71a43bbffa6045965091de4d48b868 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:04:28 -0400 Subject: [PATCH 130/150] deploy --- Scripts/upload_framework.sh | 0 Scripts/upload_remote_view_frameworks.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Scripts/upload_framework.sh mode change 100644 => 100755 Scripts/upload_remote_view_frameworks.sh diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh old mode 100644 new mode 100755 diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_remote_view_frameworks.sh old mode 100644 new mode 100755 From a8e2d1e6a1c52f994813b6a0bd8507a45adb910d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:10:51 -0400 Subject: [PATCH 131/150] deploy --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b396cb6..3708082 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ build_project: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty artifacts: paths: - - MVMCore/build/universal/** + - MVMCore/build/universal/MVMCore.framework expire_in: 1 week only: - branches From 1099dae8b05f1930983e7f6ba625a0b0a8bb87d3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:14:15 -0400 Subject: [PATCH 132/150] deploy --- Scripts/upload_framework.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index c1e5990..a6179ed 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -25,6 +25,9 @@ echo ">>> UPLOAD START <<<" echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" +ls "${LOCALPATH}" +cat "${LOCALPATH}/Info.plist" + LOCALBASE=$(basename "${LOCALPATH}") LOCALDIR=$(dirname "${LOCALPATH}") From 25b6e31b86c06c7555f7a22a519c7bfd398301cd Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:15:35 -0400 Subject: [PATCH 133/150] deploy --- Scripts/upload_framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index a6179ed..522430e 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -25,7 +25,7 @@ echo ">>> UPLOAD START <<<" echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" -ls "${LOCALPATH}" +ls cat "${LOCALPATH}/Info.plist" LOCALBASE=$(basename "${LOCALPATH}") From df174d584090c54e7f8de00e7d6609adb427ba1f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:18:09 -0400 Subject: [PATCH 134/150] deploy --- Scripts/upload_framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 522430e..59d547f 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -25,7 +25,7 @@ echo ">>> UPLOAD START <<<" echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" -ls +ls ".." cat "${LOCALPATH}/Info.plist" LOCALBASE=$(basename "${LOCALPATH}") From 21ba4900edf1ce834f8773e791659120c8cc347d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:19:59 -0400 Subject: [PATCH 135/150] deploy --- Scripts/upload_framework.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 59d547f..5af01dd 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -25,7 +25,10 @@ echo ">>> UPLOAD START <<<" echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" -ls ".." +ls "../MVMCore" +ls "../MVMCore/build" +ls "../MVMCore/build/universal" + cat "${LOCALPATH}/Info.plist" LOCALBASE=$(basename "${LOCALPATH}") From ab6635c73e5d6ead44bc0535e910d1411109b4cb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 15:26:54 -0400 Subject: [PATCH 136/150] deploy --- Scripts/upload_framework.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 5af01dd..0f312f0 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -26,6 +26,7 @@ echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" ls "../MVMCore" +ls "../MVMCore/MVMCore" ls "../MVMCore/build" ls "../MVMCore/build/universal" From eb0b4692b18a8c390dde56c70d8d3504c0183b62 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 17:30:55 -0400 Subject: [PATCH 137/150] fixes --- .gitlab-ci.yml | 3 ++- Scripts/upload_framework.sh | 5 ----- Scripts/upload_remote_view_frameworks.sh | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3708082..43842be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,9 +14,10 @@ build_project: stage: build script: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty + - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) artifacts: paths: - - MVMCore/build/universal/MVMCore.framework + - ${BUILD_DIR}/universal/MVMCore.framework expire_in: 1 week only: - branches diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 0f312f0..5003d7e 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -25,11 +25,6 @@ echo ">>> UPLOAD START <<<" echo "Local path: ${LOCALPATH}" echo "Remote path: ${REMOTEPATH}" -ls "../MVMCore" -ls "../MVMCore/MVMCore" -ls "../MVMCore/build" -ls "../MVMCore/build/universal" - cat "${LOCALPATH}/Info.plist" LOCALBASE=$(basename "${LOCALPATH}") diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_remote_view_frameworks.sh index c495882..6e7cd65 100755 --- a/Scripts/upload_remote_view_frameworks.sh +++ b/Scripts/upload_remote_view_frameworks.sh @@ -22,5 +22,5 @@ fi #xcodebuild -workspace "../RemoteView.xcworkspace" -scheme "RemoteViewAggregate" # Remote View Versions - -./upload_framework.sh $ARTIFACTORY_URL "../MVMCore/build/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT +BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) +./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT From 7936d1d51f8a13b89d49678d5d3660d40f04d4b1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 17:55:15 -0400 Subject: [PATCH 138/150] path fix --- Scripts/upload_remote_view_frameworks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_remote_view_frameworks.sh index 6e7cd65..84c6a29 100755 --- a/Scripts/upload_remote_view_frameworks.sh +++ b/Scripts/upload_remote_view_frameworks.sh @@ -22,5 +22,5 @@ fi #xcodebuild -workspace "../RemoteView.xcworkspace" -scheme "RemoteViewAggregate" # Remote View Versions -BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) +BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) ./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT From 180c8503b0417804c4a8a5796e37477ae6e9d996 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 28 Jun 2021 17:59:37 -0400 Subject: [PATCH 139/150] path fix --- Scripts/upload_remote_view_frameworks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_remote_view_frameworks.sh index 84c6a29..1ff2744 100755 --- a/Scripts/upload_remote_view_frameworks.sh +++ b/Scripts/upload_remote_view_frameworks.sh @@ -22,5 +22,5 @@ fi #xcodebuild -workspace "../RemoteView.xcworkspace" -scheme "RemoteViewAggregate" # Remote View Versions -BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) ./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT From ff760a2c2f450cbcf0300ae12ceead3135f58ae2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 29 Jun 2021 09:29:36 -0400 Subject: [PATCH 140/150] api key change --- .gitlab-ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43842be..b58d2a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,11 +24,6 @@ build_project: - feature/testing tags: - xcode_12_2 - environment: - name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory - variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory deploy_snapshot: stage: deploy From b3da2f73742939a6ac09cd6ea58c590501ef3fd7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 29 Jun 2021 09:49:24 -0400 Subject: [PATCH 141/150] api key change --- .gitlab-ci.yml | 66 ++++++-------------------------------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b58d2a7..10060ae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,22 +3,18 @@ stages: - build - deploy -test: - stage: test - script: - - echo "This job tests something" - tags: - - xcode_12_2 +#test: +# stage: test +# script: +# - echo "This job tests something" +# tags: +# - xcode_12_2 build_project: stage: build script: - xcodebuild build -project MVMCore/MVMCore.xcodeproj -scheme FatLibrary | xcpretty - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) - artifacts: - paths: - - ${BUILD_DIR}/universal/MVMCore.framework - expire_in: 1 week only: - branches - feature/testing @@ -39,55 +35,7 @@ deploy_snapshot: url: https://oneartifactoryprod.verizon.com/artifactory variables: ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -## -#stages: -# # - test -# - build # generate the remote view framework -# - deploy # deploy the framework to Artifactory as a snapshot -# - tag # on manual confirmation, tag the repository -# - go live # move the snapshot binary on artifactory into live status -# -##run_unit_tests: -## stage: test -## script: -## - xcodebuild test -project ProjectName.xcodeproj -scheme SchemeName -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2' | xcpretty -s -## tags: -## - xcode_12 -# -#build_project: -# stage: build -# script: -# - xcodebuild build -workspace RemoteView.xcworkspace -scheme RemoteViewAggregate | xcpretty -# artifacts: -# paths: -# - RemoteViewFramework/** -# expire_in: 1 week -# only: -# - branches -# - develop -# tags: -# - xcode_12_2 -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -# -#deploy_snapshot: -# stage: deploy -# script: -# - cd Scripts && ./upload_remote_view_frameworks.sh -# only: -# - branches -# - develop -# tags: -# - bash_shell -# environment: -# name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory -# variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory -# + #promote_snapshot: # stage: go live # # Prevent artifacts from needing to re-download. Everything we need is in Artifactory. From 43135e9214bf0c3f7d088aad7a4f4b159c940241 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 29 Jun 2021 09:56:00 -0400 Subject: [PATCH 142/150] api key change --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10060ae..4f2e7aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ build_project: - BUILD_DIR=$(xcodebuild -showBuildSettings -project MVMCore/MVMCore.xcodeproj | grep BUILD_DIR) only: - branches - - feature/testing + - develop tags: - xcode_12_2 @@ -27,7 +27,7 @@ deploy_snapshot: - cd Scripts && ./upload_remote_view_frameworks.sh only: - branches - - feature/testing + - develop tags: - bash_shell environment: From 6e8c464097edc69bbe8f8cdbdfec72806fdbefdc Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Tue, 29 Jun 2021 20:04:24 +0000 Subject: [PATCH 143/150] Updating registry for logging --- .../MVMCore/Models/Model/ModelRegistry.swift | 202 +++++++++++++----- MVMCore/MVMCore/Models/ModelMapping.swift | 29 ++- 2 files changed, 167 insertions(+), 64 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 097868e..78d8657 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -10,93 +10,192 @@ public struct ModelRegistry { + /// Error object for the Model Registry. public enum Error: Swift.Error { case keyNotFound case encoderError case decoderError case decoderOther(message: String) - case decoderErrorObjectNotPresent(codingKey: CodingKey, codingPath: [CodingKey]) + case decoderErrorObjectNotPresent(codingKey: CodingKey, codingPath: [CodingKey]) case decoderErrorModelNotMapped(identifer: String? = nil, codingKey: CodingKey? = nil, codingPath: [CodingKey]? = nil) + case duplicateRegistration(message: String) case other(message: String) case handlerNotMapped(identifer: String? = nil, categoryName: String? = nil) } - private struct Category { + public struct Category { var name: String var codingKey: String var instanceTypes: [String: ModelProtocol.Type] = [:] var handlerTypes: [String: ModelHandlerProtocol.Type] = [:] } - private static var categories: [String: Category] = [:] - - /// Registers models for Atomic use. - public static func register(handler: H.Type, for model: M.Type) throws { - //register the type - try self.register(model) + public static var categories: [String: Category] = [:] + + //-------------------------------------------------- + // MARK: - Convenient Registration + //-------------------------------------------------- + + /// A convenience wrapping function where error handling is managed within the class. + /// - Parameters: + /// - handler: The handling class taking an object of ModelHandlerProtocol.self which is used to register + /// - model: The data object of ModelProtocol.self which is used to register + public static func register(handler: H.Type, for model: M.Type) { + do { + try throwable_register(handler: handler, model: model) + } catch { + handleError(error) + } + } + + /// A convenience wrapping function where error handling is managed within the class. + /// - Parameter type: Takes an object of ModelProtocol.self which is used to register + public static func register(_ type: M.Type) { + do { + try throwable_register(type: type) + } catch { + handleError(error) + } + } + + //-------------------------------------------------- + // MARK: - Error Handling + //-------------------------------------------------- + + /// Handles an error if thrown when registering a ModelProtocol object. + /// - Parameter error: The error object produced by a thrown exception. + public static func handleError(_ error: Swift.Error) { - //get the key for the handler + guard let errorObject = MVMCoreErrorObject(title: nil, + messageToLog: nil, + code: (error as NSError).code, + domain: ErrorDomainNative, + location: #file) else { return } + + switch error as? ModelRegistry.Error { + case .keyNotFound: + errorObject.title = "Key Not Found" + case .encoderError: + errorObject.title = "Encoder Error" + case .decoderError: + errorObject.title = "Decoder Error" + case .decoderOther(let message): + errorObject.title = "Decoder Error: Other" + errorObject.messageToLog = message + case .decoderErrorObjectNotPresent(let codingKey, let codingPath): + errorObject.title = "Decoder Error: Object Not Present" + let codingPathConcat = codingPath.compactMap { $0.stringValue }.joined(separator: " ") + errorObject.messageToLog = codingKey.stringValue + codingPathConcat + case .decoderErrorModelNotMapped(let identifer, let codingKey, let codingPath): + errorObject.title = "Decoder Error: Model Not Mapped" + let codingPathConcat = codingPath?.compactMap { $0.stringValue }.joined(separator: " ") ?? "" + errorObject.messageToLog = (identifer ?? "") + (codingKey?.stringValue ?? "") + codingPathConcat + case .handlerNotMapped(let identifer, let categoryName): + errorObject.title = "Handler Not Mapped" + errorObject.messageToLog = (identifer ?? "") + (categoryName ?? "") + case .other(let message): + errorObject.title = "Other Registry Error" + errorObject.messageToLog = message + case .duplicateRegistration(let message): + errorObject.title = "Duplicate Registration" + errorObject.messageToLog = message + default: + errorObject.title = "Unknown Model Registry Error" + } + + MVMCoreLoggingHandler.addError(toLog: errorObject) + #if DEBUG + triggerCrashInDebug() + #endif + } + + #if DEBUG + private static func triggerCrashInDebug() { + fatalError() + } + #endif + + //-------------------------------------------------- + // MARK: - Throwable Registration + //-------------------------------------------------- + + /// Registers models for Atomic use. + /// - Parameters: + /// - handler: The handling class taking an object of ModelHandlerProtocol.self which is used to register + /// - model: The data object of ModelProtocol.self which is used to register + /// - Throws: An Error object of `ModelRegistry.Error` + public static func throwable_register(handler: H.Type, model: M.Type) throws { + // Register the type + try self.throwable_register(type: model) + + // Get the key for the handler let key = model.identifier - //get the category for the ModelProtocol + // Get the category for the ModelProtocol var category = getCategory(for: model) // Check to ensure the Category/Container combination doesn't exist. if category.handlerTypes[key] != nil { - throw ModelRegistry.Error.other(message: "ModelHandlerProtocol: \(String(describing: handler)) already exists in Category: \(category.name)") + throw ModelRegistry.Error.duplicateRegistration(message: "ModelHandlerProtocol: \(String(describing: handler)) already exists in Category: \(category.name)") } else { category.handlerTypes[key] = handler } + categories[category.name] = category } /// Registers models for Atomic use. - public static func register(_ type: M.Type) throws { - //get the category for the ModelProtocol + /// - Parameter type: Takes an object of ModelProtocol.self which is used to register + /// - Throws: An Error object of `ModelRegistry.Error` + public static func throwable_register(type: M.Type) throws { + // Get the category for the ModelProtocol var category = getCategory(for: type) // Check to ensure the Category/Type combination doesn't exist. if category.instanceTypes[M.identifier] != nil { - throw ModelRegistry.Error.other(message: "ModelProtocol: \(M.identifier) already exists in Category: \(M.categoryName)") + throw ModelRegistry.Error.duplicateRegistration(message: "ModelProtocol: \(M.identifier) already exists in Category: \(M.categoryName)") } + category.instanceTypes[M.identifier] = type categories[M.categoryName] = category } + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + public static func getHandler(_ model: ModelProtocol) throws -> ModelHandlerProtocol.Type { - //get the modelType + // Get the modelType let modelType = type(of: model) - - //get the category for the ModelProtocol + + // Get the category for the ModelProtocol guard let category = categories[modelType.categoryName] else { throw ModelRegistry.Error.other(message: "Category not found: \(modelType.categoryName)") } - - //get the containerProtocol for this ModelProtocol you had registered + + // Get the containerProtocol for this ModelProtocol you had registered guard let handlerType = category.handlerTypes[modelType.identifier] else { throw ModelRegistry.Error.handlerNotMapped(identifer: modelType.identifier, categoryName: category.name) } + return handlerType } - - private static func getCategory(for type: M.Type) -> Category { - return categories[type.categoryName] ?? Category(name: type.categoryName, codingKey: type.categoryCodingKey) + + public static func getCategory(for type: M.Type) -> Category { + categories[type.categoryName] ?? Category(name: type.categoryName, codingKey: type.categoryCodingKey) } - - private static func getCategory(for type: T.Type) -> Category? { + + public static func getCategory(for type: T.Type) -> Category? { // Temporary code till we find a better solution. - //if this is a protocol composotion, loop through each protocol for a category lookup - let protocols = String(describing: T.self).components(separatedBy: "&").compactMap{$0.trimmingCharacters(in: .whitespaces)} + // if this is a protocol composotion, loop through each protocol for a category lookup + let protocols = String(describing: T.self).components(separatedBy: "&").compactMap{ $0.trimmingCharacters(in: .whitespaces)} return protocols.compactMap({ (p) -> Category? in - guard let c = categories[p] else { - return nil - } - return c + categories[p] ?? nil }).first } public static func getType(for name: String, with type: T.Type) -> ModelProtocol.Type? { - return getCategory(for: type)?.instanceTypes[name] + getCategory(for: type)?.instanceTypes[name] } public static func getCodingKey(for type: T.Type) throws -> AnyCodingKey { @@ -108,12 +207,13 @@ public struct ModelRegistry { } } -extension KeyedDecodingContainer where Key: CodingKey { - +public extension KeyedDecodingContainer where Key: CodingKey { + //-------------------------------------------------- // MARK: - Decode + //-------------------------------------------------- /// Decodes to a registered model based on the identifier - public func decodeModel(codingKey: KeyedDecodingContainer.Key) throws -> T { + func decodeModel(codingKey: KeyedDecodingContainer.Key) throws -> T { guard let model: T = try decodeModelIfPresent(codingKey: codingKey) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) @@ -122,7 +222,7 @@ extension KeyedDecodingContainer where Key: CodingKey { } /// Decodes an array of registered model based on the identifiers. - public func decodeModels(codingKey: KeyedDecodingContainer.Key) throws -> [T] { + func decodeModels(codingKey: KeyedDecodingContainer.Key) throws -> [T] { guard let model: [T] = try decodeModelsIfPresent(codingKey: codingKey) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) @@ -131,7 +231,7 @@ extension KeyedDecodingContainer where Key: CodingKey { } /// Decodes an array with arrays of models based on the identifiers. - public func decodeModels2D(codingKey: KeyedDecodingContainer.Key) throws -> [[T]] { + func decodeModels2D(codingKey: KeyedDecodingContainer.Key) throws -> [[T]] { guard let models: [[T]] = try decodeModels2DIfPresent(codingKey: codingKey) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) @@ -139,25 +239,27 @@ extension KeyedDecodingContainer where Key: CodingKey { return models } + //-------------------------------------------------- // MARK: - DecodeIfPresent + //-------------------------------------------------- /// Decodes to a registered model based on the identifier, optional. - public func decodeModelIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> T? { - //create coding key + func decodeModelIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> T? { + // Create coding key let typeCodingKey = try ModelRegistry.getCodingKey(for: T.self) - //get the container that holds the identifier value + // Get the container that holds the identifier value guard contains(codingKey), - let container = try? self.nestedContainer(keyedBy: AnyCodingKey.self, forKey: codingKey), - let identifier = try container.decodeIfPresent(String.self, forKey: typeCodingKey) else { return nil } + let container = try? self.nestedContainer(keyedBy: AnyCodingKey.self, forKey: codingKey), + let identifier = try container.decodeIfPresent(String.self, forKey: typeCodingKey) else { return nil } - //get the type from the identifier value in the Registry + // Get the type from the identifier value in the Registry guard let type = ModelRegistry.getType(for: identifier, with: T.self) else { MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelProtocol not mapped: \(identifier)") throw ModelRegistry.Error.decoderErrorModelNotMapped(identifer: identifier, codingKey: typeCodingKey, codingPath: container.codingPath) } - //decode the type using the decoder + // Decode the type using the decoder let model = try type.decode(keyedContainer: self, codingKey: codingKey) if let model = model as? T { @@ -169,19 +271,19 @@ extension KeyedDecodingContainer where Key: CodingKey { } /// Decodes an array of registered model based on the identifiers, optional. - public func decodeModelsIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [T]? { + func decodeModelsIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [T]? { guard contains(codingKey), - var container = try? self.nestedUnkeyedContainer(forKey: codingKey) - else { return nil } + var container = try? self.nestedUnkeyedContainer(forKey: codingKey) + else { return nil } return try container.decodeModelsIfPresent() } /// Decodes an array with arrays of models based on the identifiers, optional. - public func decodeModels2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[T]]? { + func decodeModels2DIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [[T]]? { guard contains(codingKey), - var container = try? nestedUnkeyedContainer(forKey: codingKey) - else { return nil } + var container = try? nestedUnkeyedContainer(forKey: codingKey) + else { return nil } return try container.decodeModels2DIfPresent() } @@ -259,6 +361,7 @@ public extension UnkeyedDecodingContainer { throw ModelRegistry.Error.decoderError } } + return models } @@ -277,6 +380,7 @@ public extension UnkeyedDecodingContainer { } modelLists.append(models) } + return modelLists } } diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 26cb696..d5e602d 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -8,22 +8,21 @@ @objcMembers open class ModelMapping: NSObject { - open class func registerObjects() {} + open class func registerObjects() { } open class func registerActions() { - try? ModelRegistry.register(ActionOpenPageModel.self) - try? ModelRegistry.register(ActionOpenUrlModel.self) - try? ModelRegistry.register(ActionCallModel.self) - try? ModelRegistry.register(ActionBackModel.self) - try? ModelRegistry.register(ActionShareModel.self) - try? ModelRegistry.register(ActionRestartModel.self) - try? ModelRegistry.register(ActionPreviousSubmitModel.self) - try? ModelRegistry.register(ActionCancelModel.self) - try? ModelRegistry.register(ActionSettingModel.self) - try? ModelRegistry.register(ActionNoopModel.self) - try? ModelRegistry.register(ActionActionsModel.self) - try? ModelRegistry.register(ActionOpenSMSModel.self) - try? ModelRegistry.register(ActionContactModel.self) + ModelRegistry.register(ActionOpenPageModel.self) + ModelRegistry.register(ActionOpenUrlModel.self) + ModelRegistry.register(ActionCallModel.self) + ModelRegistry.register(ActionBackModel.self) + ModelRegistry.register(ActionShareModel.self) + ModelRegistry.register(ActionRestartModel.self) + ModelRegistry.register(ActionPreviousSubmitModel.self) + ModelRegistry.register(ActionCancelModel.self) + ModelRegistry.register(ActionSettingModel.self) + ModelRegistry.register(ActionNoopModel.self) + ModelRegistry.register(ActionActionsModel.self) + ModelRegistry.register(ActionOpenSMSModel.self) + ModelRegistry.register(ActionContactModel.self) } } - From d5a66f61a24fc98280f774c5f18312811114f42f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 30 Jun 2021 10:53:04 -0400 Subject: [PATCH 144/150] removing remote view stuff --- .gitlab-ci.yml | 4 ++-- ...emote_view_frameworks.sh => upload_core_frameworks.sh} | 8 +++----- Scripts/upload_framework.sh | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) rename Scripts/{upload_remote_view_frameworks.sh => upload_core_frameworks.sh} (62%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f2e7aa..6abe3f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ stages: - - test +# - test - build - deploy @@ -24,7 +24,7 @@ build_project: deploy_snapshot: stage: deploy script: - - cd Scripts && ./upload_remote_view_frameworks.sh + - cd Scripts && ./upload_core_frameworks.sh only: - branches - develop diff --git a/Scripts/upload_remote_view_frameworks.sh b/Scripts/upload_core_frameworks.sh similarity index 62% rename from Scripts/upload_remote_view_frameworks.sh rename to Scripts/upload_core_frameworks.sh index 1ff2744..714cf16 100755 --- a/Scripts/upload_remote_view_frameworks.sh +++ b/Scripts/upload_core_frameworks.sh @@ -1,10 +1,10 @@ #!/bin/sh -e -# upload_remote_view_frameworks.sh +# upload_core_frameworks.sh # -# Uploads all compiled framework flavors in RemoteViewFramework to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. +# Uploads all compiled framework flavors in MVMCore to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. # -# Created by Hedden, Kyle Matthew on 3/2/18. +# Copied from Hedden, Kyle Matthew on 3/2/18. # FRAMEWORK_VERSION=$(cd ../MVMCore && agvtool vers -terse) @@ -19,8 +19,6 @@ if [ -z $ARTIFACTORY_URL ]; then ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" fi -#xcodebuild -workspace "../RemoteView.xcworkspace" -scheme "RemoteViewAggregate" - # Remote View Versions BUILD_DIR=$(xcodebuild -showBuildSettings -project ../MVMCore/MVMCore.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) ./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/MVMCore.framework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/[VER]/MVMCore-[VER]-Debug-SNAPSHOT diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh index 5003d7e..94a6007 100755 --- a/Scripts/upload_framework.sh +++ b/Scripts/upload_framework.sh @@ -1,7 +1,6 @@ #!/bin/bash -e # upload_framework.sh -# RemoteView # # Uploads an iOS framework to Artificatory given the local path as the first argument and the remote project name in Verizon OneArtifactory for the second argument. # @@ -9,7 +8,7 @@ # # The script will replace [VER] in the provided remote path with the version found in the framework bundle. # -# Created by Hedden, Kyle Matthew on 3/2/18. +# Copied from Hedden, Kyle Matthew on 3/2/18. # Copyright © 2018 Verizon. All rights reserved. URL=$1 From 5c15bbb8a8300869883be74604ad7da93aaa45fe Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 13:39:31 -0400 Subject: [PATCH 145/150] fix for script --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index cb79f15..8ab5c06 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -825,7 +825,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\"\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; }; /* End PBXShellScriptBuildPhase section */ From 4d7bc54145c45c25d6811dd1195f331367b570d0 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:22:01 -0400 Subject: [PATCH 146/150] script fix for swift modules --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 8ab5c06..ca0ef23 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -825,7 +825,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\n\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/* \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ From de8389513060ab40c4cc2c588aed09536bed1289 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:33:37 -0400 Subject: [PATCH 147/150] fix copy --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index ca0ef23..88788e8 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -825,7 +825,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\n\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/* \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -a ${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/ \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ From 85c7ea347c3ce7688516a50cd9d4601dd6ea6dbb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 1 Jul 2021 14:40:32 -0400 Subject: [PATCH 148/150] fix missing bracket --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 88788e8..ac92e61 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -825,7 +825,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -a ${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/ \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH}/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -a \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ From 3a4e317ccf82c9791c678d2d117e3c9238c35a52 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Thu, 15 Jul 2021 13:32:29 +0000 Subject: [PATCH 149/150] 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"; From 83b49a69a2fc49b24c6905639656c50acb2c5ec9 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 22 Jul 2021 15:49:33 -0400 Subject: [PATCH 150/150] nullability change --- MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h index dba1c92..2f122a8 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewControllerProtocol.h @@ -16,7 +16,7 @@ @property (nullable, strong, nonatomic) NSString *pageType; // This view controller should subclass this function and check the load to make sure it has all the needed data. Fills the error object if there are any errors. Returns if we should finish the load or not. Ideally error should use code ErrorCodeViewControllerProcessingJSON. -- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error; +- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nullable *_Nonnull)error; @optional