Merge branch 'bugfix/CXTDT-149032' into 'release/8_4_0'
Bugfix/cxtdt 149032 See merge request BPHV_MIPS/mvm_core!136
This commit is contained in:
commit
5fb396cec5
@ -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 = "<group>"; };
|
||||
016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = "<group>"; };
|
||||
016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterProtocol.swift; sourceTree = "<group>"; };
|
||||
016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActionHandler+ClientParameters.swift"; sourceTree = "<group>"; };
|
||||
01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = "<group>"; };
|
||||
01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = "<group>"; };
|
||||
01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = "<group>"; };
|
||||
@ -585,7 +583,6 @@
|
||||
AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */,
|
||||
AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */,
|
||||
AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */,
|
||||
016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */,
|
||||
);
|
||||
path = ActionHandling;
|
||||
sourceTree = "<group>";
|
||||
@ -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 */,
|
||||
|
||||
@ -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("clientParameters") 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)")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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 <MVMCoreActionDelegateProtocol>*)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
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#import "MVMCorePresentationDelegateProtocol.h"
|
||||
#import <SafariServices/SafariServices.h>
|
||||
#import <MVMCore/MVMCore-Swift.h>
|
||||
#import "MVMCoreLoadingOverlayHandler.h"
|
||||
|
||||
NSString * const KeyActionType = @"actionType";
|
||||
NSString * const KeyActionTypeLinkAway = @"openURL";
|
||||
@ -128,7 +129,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
}];
|
||||
};
|
||||
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
|
||||
@ -293,7 +294,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
[weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject];
|
||||
};
|
||||
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
[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 {
|
||||
@ -443,7 +444,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
}];
|
||||
};
|
||||
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
@ -562,7 +563,55 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
[weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate];
|
||||
};
|
||||
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (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<NSString *,id> * _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 parameters"];
|
||||
stopLoadingOverlay();
|
||||
completionHandler(actionInformation);
|
||||
}
|
||||
}];
|
||||
|
||||
if (error) {
|
||||
stopLoadingOverlay();
|
||||
completionHandler(actionInformation);
|
||||
[MVMCoreLoggingHandler addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"MVMCoreActionHandler->setClientParameter"]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user