modernization

This commit is contained in:
Scott Pfeil 2022-07-19 14:36:57 -04:00
commit 90adc247d1
13 changed files with 84 additions and 368 deletions

View File

@ -137,8 +137,6 @@
AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96AF1FBA3B590008D868 /* MVMCoreGetterUtility.m */; };
AFBB96B81FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96B91FBA3CEC0008D868 /* MVMCoreActionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96BA1FBA3CEC0008D868 /* MVMCoreActionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */; };
AFBB96EC1FBA4A260008D868 /* MFHardCodedServerResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */; };
AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */; };
AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -162,8 +160,8 @@
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 */; };
D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler.swift */; };
D27073D125BB844B001C7246 /* ActionDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27073D025BB844B001C7246 /* ActionDelegateProtocol.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 */; };
D288D5F526C6EFE000A5C365 /* MVMCoreLoggingHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D288D5F426C6EFE000A5C365 /* MVMCoreLoggingHandler+Extension.swift */; };
@ -300,8 +298,6 @@
AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGetterUtility.h; sourceTree = "<group>"; };
AFBB96AF1FBA3B590008D868 /* MVMCoreGetterUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreGetterUtility.m; sourceTree = "<group>"; };
AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreActionDelegateProtocol.h; sourceTree = "<group>"; };
AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreActionHandler.h; sourceTree = "<group>"; };
AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreActionHandler.m; sourceTree = "<group>"; };
AFBB96D21FBA44420008D868 /* VZWAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VZWAuthentication.framework; path = ../../SharedFrameworks/VZWAuthentication.framework; sourceTree = "<group>"; };
AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFHardCodedServerResponse.h; sourceTree = "<group>"; };
AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFHardCodedServerResponse.m; sourceTree = "<group>"; };
@ -326,8 +322,8 @@
D268D82926700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewManagerViewControllerProtocolHelper.h; sourceTree = "<group>"; };
D268D82A26700292008BD413 /* MVMCoreViewManagerViewControllerProtocolHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreViewManagerViewControllerProtocolHelper.m; sourceTree = "<group>"; };
D27073B625BB45C4001C7246 /* ActionActionsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionActionsModel.swift; sourceTree = "<group>"; };
D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionHandler+Extension.swift"; sourceTree = "<group>"; };
D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionDelegateProtocol+Extension.swift"; sourceTree = "<group>"; };
D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreActionHandler.swift; sourceTree = "<group>"; };
D27073D025BB844B001C7246 /* ActionDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionDelegateProtocol.swift; sourceTree = "<group>"; };
D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreGetterUtility+Extension.swift"; sourceTree = "<group>"; };
D282AAB72240342D00C46919 /* NSNumber+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSNumber+Extension.swift"; sourceTree = "<group>"; };
D288D5F426C6EFE000A5C365 /* MVMCoreLoggingHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreLoggingHandler+Extension.swift"; sourceTree = "<group>"; };
@ -634,10 +630,8 @@
isa = PBXGroup;
children = (
AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */,
D27073D025BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift */,
AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */,
AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */,
D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift */,
D27073D025BB844B001C7246 /* ActionDelegateProtocol.swift */,
D27073CC25BB4CEF001C7246 /* MVMCoreActionHandler.swift */,
946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */,
AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */,
AF130B8D2788DF6E00C6C03C /* OpenURLOptionsModel.swift */,
@ -788,7 +782,6 @@
AF43A5831FBB66DE008E9347 /* MVMCoreConstants.h in Headers */,
AFED77A81FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.h in Headers */,
AFEEE8191FCDEB8D00B5EDD0 /* MVMCoreLoggingDelegateProtocol.h in Headers */,
AFBB96B91FBA3CEC0008D868 /* MVMCoreActionHandler.h in Headers */,
AF43A74C1FC6109F008E9347 /* MVMCoreSessionObject.h in Headers */,
8876D5F41FB50AB000EB2E3D /* UILabel+MFCustom.h in Headers */,
AFFCFA681FCCC0D700FD0730 /* MVMCoreLoadingViewControllerProtocol.h in Headers */,
@ -910,7 +903,6 @@
01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */,
8876D5ED1FB50AB000EB2E3D /* NSDictionary+MFConvenience.m in Sources */,
AFBB968C1FBA3A9A0008D868 /* MVMCoreDismissViewControllerOperation.m in Sources */,
AFBB96BA1FBA3CEC0008D868 /* MVMCoreActionHandler.m in Sources */,
AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */,
AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */,
D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */,
@ -951,7 +943,7 @@
0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */,
AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */,
AF69D4F5286E9F5900BC6862 /* ActionSettingHandler.swift in Sources */,
D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift in Sources */,
D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler.swift in Sources */,
01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */,
8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */,
AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */,
@ -970,7 +962,7 @@
EA09CD62282ACDDB00A7835F /* Decoder+UserInfo.swift in Sources */,
EA09CD99282BF83600A7835F /* DecodableDefault.swift in Sources */,
01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */,
D27073D125BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift in Sources */,
D27073D125BB844B001C7246 /* ActionDelegateProtocol.swift in Sources */,
AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */,
AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */,
AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */,

View File

@ -0,0 +1,36 @@
//
// MVMCoreActionDelegateProtocolExtension.swift
// MVMCore
//
// Created by Scott Pfeil on 1/22/21.
// Copyright © 2021 myverizon. All rights reserved.
//
import Foundation
public protocol ActionDelegateProtocol: MVMCoreActionDelegateProtocol {
/// Allows the delegate to cancel the action.
func shouldPerform(action: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) -> Bool
/// Allows the delegate to create the request parameters as desired.
func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) throws -> (MVMCoreRequestParameters,[AnyHashable : Any]?)
/// Allows the delegate to handle any custom actions that are not registered with the Action Handler.
func handlesUnknownAction(for model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> Bool
}
public extension ActionDelegateProtocol {
func shouldPerform(action: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) -> Bool {
return true
}
func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable : Any]? = nil) throws -> (MVMCoreRequestParameters,[AnyHashable : Any]?) {
let json = try MVMCoreActionHandler.convertActionToJSON(model)
return (MVMCoreRequestParameters(actionMap: json)!,additionalData)
}
func handlesUnknownAction(for model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> Bool {
return false
}
}

View File

@ -15,8 +15,11 @@ open class ActionOpenPageHandler: MVMCoreActionHandlerProtocol {
open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
guard let model = model as? ActionOpenPageModel else { return }
var requestParameters: MVMCoreRequestParameters
if let _ = delegateObject?.actionDelegate?.getRequestParameters {
requestParameters = try delegateObject!.actionDelegate!.getRequestParameters(for: model, delegateObject: delegateObject, additionData: additionalData)
var additionalData = additionalData
if let _ = (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.getRequestParameters {
let value = try (delegateObject!.actionDelegate! as! ActionDelegateProtocol).getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData)
requestParameters = value.0
additionalData = value.1
} else {
let json = try MVMCoreActionHandler.convertActionToJSON(model)
requestParameters = MVMCoreRequestParameters(actionMap: json)!

View File

@ -1,23 +0,0 @@
//
// MVMCoreActionDelegateProtocolExtension.swift
// MVMCore
//
// Created by Scott Pfeil on 1/22/21.
// Copyright © 2021 myverizon. All rights reserved.
//
import Foundation
public extension MVMCoreActionDelegateProtocol {
/// Allows the delegate to cancel the action.
func shouldPerform(action: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) -> Bool {
return true
}
/// Allows the delegate to create the request parameters as desired.
func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionData: [AnyHashable : Any]? = nil) throws -> MVMCoreRequestParameters {
let json = try MVMCoreActionHandler.convertActionToJSON(model)
return MVMCoreRequestParameters(actionMap: json)!
}
}

View File

@ -1,67 +0,0 @@
//
// MVMCoreActionHandler.h
// myverizon
//
// Created by Scott Pfeil on 11/20/15.
// Copyright © 2015 Verizon Wireless. All rights reserved.
//
// Can be subclassed to handle app specific actions as well.
//#import <Foundation/Foundation.h>
//#import <MVMCore/MVMCoreActionDelegateProtocol.h>
//#import <MVMCore/MVMCoreLoadDelegateProtocol.h>
//#import <MVMCore/MVMCorePresentationDelegateProtocol.h>
//@class DelegateObject;
//
//extern NSString * _Nonnull const KeyActionType;
//extern NSString * _Nonnull const KeyActionTypeLinkAway;
//extern NSString * _Nonnull const KeyActionTypeOpen;
//
//@interface MVMCoreActionHandler : NSObject
//
///// 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
//- (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..
//- (void)handleAction:(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)getClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler;
//
//#pragma mark - Actions
//
///// 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;
//
///// 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
//- (void)unknownAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
//
///// Handles action errors.
//- (void)handleActionError:(nullable MVMCoreErrorObject *)error 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.
//+ (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 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;
//
///// 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
//- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
//
//@end

View File

@ -1,176 +0,0 @@
////
//// MVMCoreActionHandler.m
//// myverizon
////
//// Created by Scott Pfeil on 11/20/15.
//// Copyright © 2015 Verizon Wireless. All rights reserved.
////
//
//#import <MVMCore/MVMCoreActionHandler.h>
//#import "MVMCoreLoggingHandler.h"
//#import "MVMCoreCache.h"
//#import "MVMCoreSessionTimeHandler.h"
//#import "MVMCoreLoadHandler.h"
//#import "MVMCoreNavigationHandler.h"
//#import "MVMCoreDispatchUtility.h"
//#import "NSDictionary+MFConvenience.h"
//#import "MVMCoreGetterUtility.h"
//#import "MVMCoreRequestParameters.h"
//#import "MVMCoreErrorObject.h"
//#import "MVMCoreJSONConstants.h"
//#import "MVMCoreHardcodedStringsConstants.h"
//#import "MVMCoreErrorConstants.h"
//#import "MVMCoreActionUtility.h"
//#import "MVMCoreSessionObject.h"
//#import "MVMCoreObject.h"
//#import "MVMCorePresentationDelegateProtocol.h"
//#import <SafariServices/SafariServices.h>
//#import <MVMCore/MVMCore-Swift.h>
//#import "MVMCoreLoadingOverlayHandler.h"
//#import <ContactsUI/ContactsUI.h>
//
//NSString * const KeyActionType = @"actionType";
//NSString * const KeyActionTypeLinkAway = @"openURL";
//NSString * const KeyActionTypeOpen = @"openPage";
//
//@interface MVMCoreActionHandler() <CNContactViewControllerDelegate, CNContactPickerDelegate>
//@end
//
//@implementation MVMCoreActionHandler
//+ (nullable instancetype)sharedActionHandler {
// return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].actionHandler classToVerify:self];
//}
//
//- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// [self handleActionWith:dictionary additionalData:additionalData delegateObject:delegateObject];
//}
//
//- (void)handleAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// [self handleActionWith:actionInformation additionalData:additionalData delegateObject:delegateObject];
//}
//
//- (void)getClientParameter:(nullable NSDictionary *)clientParametersMap requestParameters:(nullable NSDictionary *)requestParameters showLoadingOverlay:(BOOL)showLoadingOverlay completionHandler:(nonnull void (^)(NSDictionary * _Nullable parameters))completionHandler {
//
// if (!clientParametersMap) {
// completionHandler(nil);
// return;
// }
//
// if (showLoadingOverlay) {
// [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading];
// }
//
// void (^stopLoadingOverlay)(void) = ^(void) {
// if (showLoadingOverlay) {
// [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:true];
// }
// };
//
// NSError *error = nil;
// [MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"];
//
// ClientParameterHandler *clientParameterHandler = [[ClientParameterHandler alloc] init];
// [clientParameterHandler getParametersWith:clientParametersMap
// requestParameters:requestParameters
// error:&error
// completionHandler:^(NSDictionary<NSString *,id> * _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();
// completionHandler(nil);
// [MVMCoreLoggingHandler addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler->setClientParameter"]];
// }
//}
//
//#pragma mark - Actions
//
//- (void)logAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// if ([delegateObject.actionDelegate respondsToSelector:@selector(logActionWithActionInformation:additionalData:)]) {
// [delegateObject.actionDelegate logActionWithActionInformation:actionInformation additionalData:additionalData];
// } else {
// [[self class] defaultLogAction:actionInformation additionalData:additionalData delegateObject:delegateObject];
// }
//}
//
//
//
//- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// return NO;
//}
//
//- (void)unknownAction:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// if ([delegateObject.actionDelegate respondsToSelector:@selector(handleUnknownActionType:actionInformation:additionalData:)]) {
// [delegateObject.actionDelegate handleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData];
// } else {
// [MVMCoreActionHandler defaultHandleUnknownActionType:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject];
// }
//}
//
//- (void)handleActionError:(nullable MVMCoreErrorObject *)error actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
// if (error) {
// if ([delegateObject.actionDelegate respondsToSelector:@selector(handleActionError:additionalData:)]) {
// [delegateObject.actionDelegate handleActionError:error additionalData:additionalData];
// } else {
// [self defaultHandleActionError:error additionalData:additionalData];
// }
// }
//}
//
//#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.
//}
//
//+ (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 addRequestParameters:jsonDictionary];
// [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject];
// }];
// } else {
// [[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:delegateObject];
// }
//}
//
//+ (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
//
// MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegateObject.actionDelegate class]),actionType]];
// [[self sharedActionHandler] defaultHandleActionError:error additionalData:additionalData];
//}
//
//- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData {
//
// // Logs the error.
// if (error.logError) {
// [MVMCoreLoggingHandler addErrorToLog:error];
// }
//}
//
//#pragma mark - Deprecated
//
//- (void)handleActionWithDictionary:(nullable NSDictionary *)dictionary additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
//
// DelegateObject *delegateObject = [[DelegateObject alloc] init];
// delegateObject.actionDelegate = delegate;
// delegateObject.presentationDelegate = delegate;
// delegateObject.loadDelegate = delegate;
// [self handleActionWithDictionary:dictionary additionalData:additionalData delegateObject:delegateObject];
//}
//
//@end

View File

@ -1,5 +1,5 @@
//
// MVMCoreActionHandler+Extension.swift
// MVMCoreActionHandler.swift
// MVMCore
//
// Created by Scott Pfeil on 1/22/21.
@ -84,7 +84,7 @@ extension MVMCoreActionHandlerProtocol {
/// Handles the error by calling actionDelegate handleActionError, else ActionHandler defaultHandleActionError.
open func handle(errorObject: MVMCoreErrorObject, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable: Any]? = nil) {
delegateObject?.actionDelegate?.handleActionError?(errorObject, additionalData: additionalData) ?? MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData)
delegateObject?.actionDelegate?.handleActionError?(errorObject, additionalData: additionalData) ?? defaultHandleActionError(errorObject, additionalData: additionalData)
}
/// Returns a common description for the error location.
@ -94,30 +94,11 @@ extension MVMCoreActionHandlerProtocol {
// MARK: - Action Handling
/// Legacy handle action with json.
@objc(handleActionWithDictionary:additionalData:delegateObject:)
open func handleAction(with json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ActionHandler: json \(String(describing: json))")
Task(priority: .userInitiated) {
do {
guard let json = json else {
throw ModelRegistry.Error.keyNotFound
}
let model = try MVMCoreActionHandler.createModel(with: json, delegateObject: delegateObject)
_ = asyncHandleAction(with: model, additionalData: additionalData, delegateObject: delegateObject)
} catch {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ActionHandler: Error \(error)")
let errorObject = getActionErrorObject(for: error, actionType: json?.stringForkey(KeyActionType) ?? "noAction", delegateObject: delegateObject)
handle(errorObject: errorObject, delegateObject: delegateObject, additionalData: additionalData)
}
}
}
/// Handle an action with the given model.
open func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) async throws {
try Task.checkCancellation()
// Allow the delegate to intercept.
guard delegateObject?.actionDelegate?.shouldPerform(action: model, additionalData: additionalData, delegateObject: delegateObject) ?? true else { return }
guard (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.shouldPerform(action: model, additionalData: additionalData, delegateObject: delegateObject) ?? true else { return }
// Log the action
logAction(with: model, additionalData: additionalData, delegateObject: delegateObject)
@ -174,12 +155,13 @@ extension MVMCoreActionHandlerProtocol {
/// Subclass to log the action was fired.
open func logAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
// Calls legacy log action function.
delegateObject?.actionDelegate?.logAction?(withActionInformation: model.toJSON(), additionalData: additionalData)
}
/// Subclass to handle and any actions where a handler was not registered. Return if it was handled or not.
/// Subclass to handle and any actions where a handler was not registered. Checks with the delegate handlesUnknownAction function
open func handleUnregisteredAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) async throws -> Bool {
return false
return try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.handlesUnknownAction(for: model, delegateObject: delegateObject, additionalData: additionalData) ?? false
}
/// Logs the error.
@ -187,4 +169,25 @@ extension MVMCoreActionHandlerProtocol {
guard error.logError else { return }
MVMCoreLoggingHandler.addError(toLog: error)
}
// MARK: - Legacy Holdovers
/// Legacy handle action with json.
@objc(handleActionWithDictionary:additionalData:delegateObject:)
open func handleAction(with json: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ActionHandler: json \(String(describing: json))")
Task(priority: .userInitiated) {
do {
guard let json = json else {
throw ModelRegistry.Error.keyNotFound
}
let model = try MVMCoreActionHandler.createModel(with: json, delegateObject: delegateObject)
_ = asyncHandleAction(with: model, additionalData: additionalData, delegateObject: delegateObject)
} catch {
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ActionHandler: Error \(error)")
let errorObject = getActionErrorObject(for: error, actionType: json?.stringForkey(KeyActionType) ?? "noAction", delegateObject: delegateObject)
handle(errorObject: errorObject, delegateObject: delegateObject, additionalData: additionalData)
}
}
}
}

View File

@ -11,7 +11,7 @@ import Foundation
public extension MVMCoreLoadHandler {
/// Performs the request.
func performRequest(with requestParameters: MVMCoreRequestParameters, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
// Makes the request and waits for it.
// Makes the request and waits for it. TODO: Any way to take errors into account?
guard let operation = MVMCoreLoadHandler.sharedGlobal()?.loadRequest(requestParameters, dataForPage: additionalData, delegateObject: delegateObject) else { return }
await withCheckedContinuation { continuation in
operation.completionBlock = {

View File

@ -68,12 +68,4 @@
// By default, returns continue loading and decides not to throw an error.
+ (BOOL)defaultHandleModuleError:(nonnull NSString *)module loadObject:(nonnull MVMCoreLoadObject *)loadObject error:(nonnull MVMCoreErrorObject *)error;
#pragma mark - Deprecated
// Loads a blocking request with the passed in parameters and data for the next page. Pass in the data to handle certain functions.
- (nonnull MVMCoreLoadRequestOperation *)loadRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
// Loads a background request with the passed in parameters and data for the next page. Pass in the data to handle certain functions.
- (nonnull MVMCoreLoadRequestOperation *)loadBackgroundRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate __deprecated;
@end

View File

@ -312,8 +312,8 @@
}
MVMCoreLog(@"********************************* Cookie Sent *********************************");
[[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
MVMCoreLog(@"Cookie Name: %@, Cookie Value: %@",obj.name, obj.value);
[[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:request.URL] enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
MVMCoreLog(@"Cookie Name: %@, Cookie Value: %@, Domain: %@", obj.name, obj.value, obj.domain);
}];
[[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationGoingToServer object:nil];
@ -430,20 +430,4 @@
return YES;
}
#pragma mark - Deprecated
- (MVMCoreLoadRequestOperation *)loadRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
MVMCoreLoadRequestOperation *loadOperation = [[MVMCoreLoadRequestOperation alloc] initWithRequestParameters:requestParameters dataForPage:dataForPage delegate:delegate backgroundLoad:NO];
[self.blockingLoadQueue addOperation:loadOperation];
return loadOperation;
}
- (MVMCoreLoadRequestOperation *)loadBackgroundRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
MVMCoreLoadRequestOperation *loadOperation = [[MVMCoreLoadRequestOperation alloc] initWithRequestParameters:requestParameters dataForPage:dataForPage delegate:delegate backgroundLoad:YES];
[self.backgroundLoadQueue addOperation:loadOperation];
return loadOperation;
}
@end

View File

@ -61,8 +61,11 @@
}
- (BOOL)extendsAppSession {
NSNumber *extendSessionFlag = [self.responseInfoMap optionalNumberForKey:@"appSessionExtended"];
return extendSessionFlag == nil || [extendSessionFlag boolValue]; // Default to YES if the key does not exist.
//NSNumber *extendSessionFlag = [self.responseInfoMap optionalNumberForKey:@"appSessionExtended"];
//return extendSessionFlag == nil || [extendSessionFlag boolValue]; // Default to YES if the key does not exist.
// With the introduciton of NSA and OIDC tokens, we can no longer rely on BAU network touches to update our server session.
return NO;
}
#pragma mark - Deprecated

View File

@ -21,7 +21,6 @@
@property (nullable, strong, nonatomic) MVMCoreRequestParameters *requestParameters;
@property (nullable, strong, nonatomic) MVMCoreLoadObject *loadObject;
@property (nullable, strong, nonatomic) NSDictionary *dataForPage;
@property (nullable, strong, nonatomic) NSObject <MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol> *delegate;// __deprecated;
@property (nullable, strong, nonatomic) DelegateObject *delegateObject;
@property (nonatomic) BOOL backgroundLoad;
@property (nonatomic, getter=areDependenciesAdded) BOOL dependenciesAdded;
@ -105,8 +104,4 @@
* @param loadObject The load data **/
+ (void)loadFinished:(nonnull MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController errorObject:(nullable MVMCoreErrorObject *)errorObject;
#pragma mark - Deprecated
- (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate backgroundLoad:(BOOL)backgroundLoad __deprecated;
@end

View File

@ -902,30 +902,4 @@
}
}
#pragma mark - Deprecated
- (void)setDelegateObject:(DelegateObject *)delegateObject {
_delegateObject = delegateObject;
_delegate = delegateObject.loadDelegate;
}
- (void)setDelegate:(NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol> *)delegate {
_delegate = delegate;
if ([delegate respondsToSelector:@selector(delegateObject)]) {
_delegateObject = [delegate performSelector:@selector(delegateObject)];
} else {
_delegateObject = [DelegateObject createWithDelegateForAll:delegate];
}
}
- (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate backgroundLoad:(BOOL)backgroundLoad {
if (self = [super init]) {
self.requestParameters = requestParameters;
self.dataForPage = dataForPage;
self.delegate = delegate;
self.backgroundLoad = backgroundLoad;
}
return self;
}
@end