From 87e02c37b75999a7ffd7a6fd306f0400b3d95979 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Thu, 31 Dec 2020 14:44:01 +0530 Subject: [PATCH 1/3] top notification action implementation --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ .../Atomic/Actions/ActionTopAlertModel.swift | 7 ------ .../Actions/ActionTopNotificationModel.swift | 24 +++++++++++++++++++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../OtherHandlers/MVMCoreUIActionHandler.h | 3 +++ .../OtherHandlers/MVMCoreUIActionHandler.m | 11 +++++++++ MVMCoreUI/Utility/MVMCoreUIConstants.h | 1 + MVMCoreUI/Utility/MVMCoreUIConstants.m | 1 + 8 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3fce1455..2dc86525 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -290,6 +290,7 @@ BBC0C4FF24811DCA0087C44F /* TagModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC0C4FE24811DCA0087C44F /* TagModel.swift */; }; C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; }; C07065C42395677300FBF997 /* Link.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07065C32395677300FBF997 /* Link.swift */; }; + C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */; }; C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; }; C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; }; C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; }; @@ -833,6 +834,7 @@ BBC0C4FE24811DCA0087C44F /* TagModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagModel.swift; sourceTree = ""; }; C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; C07065C32395677300FBF997 /* Link.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Link.swift; sourceTree = ""; }; + C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopNotificationModel.swift; sourceTree = ""; }; C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = ""; }; C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = ""; }; C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = ""; }; @@ -1308,6 +1310,7 @@ D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */, D2ED27EA254B0CE700A1C293 /* AlertModel.swift */, D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */, + C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */, ); path = Actions; sourceTree = ""; @@ -2432,6 +2435,7 @@ 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */, D2CAC7CF2511052300C75681 /* CollapsableNotificationModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, + C6687441259D92D400F32D13 /* ActionTopNotificationModel.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 1e93d98f..0fb9d00d 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -13,7 +13,6 @@ import Foundation public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier public var pageType: String? - public var topNotification: TopNotificationModel? public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? @@ -22,10 +21,4 @@ import Foundation self.extraParameters = extraParameters self.analyticsData = analyticsData } - - public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { - self.topNotification = topNotification - self.extraParameters = extraParameters - self.analyticsData = analyticsData - } } diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift new file mode 100644 index 00000000..c1c362c5 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift @@ -0,0 +1,24 @@ +// +// ActionTopNotificationModel.swift +// MVMCoreUI +// +// Created by Murugan, Vimal on 31/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers public class ActionTopNotificationModel: ActionModelProtocol { + + public static var identifier: String = "topNotification" + public var actionType: String = ActionTopNotificationModel.identifier + public var topNotification: TopNotificationModel? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + public init(topNotification: TopNotificationModel, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.topNotification = topNotification + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index ff262876..559b611b 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -259,6 +259,7 @@ import Foundation try? ModelRegistry.register(ActionTopAlertModel.self) try? ModelRegistry.register(ActionCollapseNotificationModel.self) try? ModelRegistry.register(ActionOpenPanelModel.self) + try? ModelRegistry.register(ActionTopNotificationModel.self) // MARK:- Behaviors try? ModelRegistry.register(ScreenBrightnessModifierBehavior.self) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index 3835207b..b18a2249 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN // Collapses the current top notification - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; +// Shows a topnotification new molecular +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; + #pragma mark - Deprecated // Shows a popup diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 5ca372cd..bafdd418 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -31,6 +31,9 @@ } else if ([actionType isEqualToString:KeyActionTypeAlert]) { [self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject]; return YES; + } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { + [self topNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; + return YES; } return NO; } @@ -112,6 +115,14 @@ } } +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + //Handle molecular topnotification + NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; + if (topNotification) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + } +} + - (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { [super defaultHandleActionError:error additionalData:additionalData]; if (!error.silentError) { diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index b96d50ed..ab77986b 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -48,6 +48,7 @@ extern NSString * const KeyActionTypePopup; extern NSString * const KeyActionTypeAlert; extern NSString * const KeyActionTypeTopAlert; extern NSString * const KeyActionTypeCollapseNotification; +extern NSString * const KeyActionTypeTopNotification; /// Key for molecular top notification architecture. extern NSString * const KeyTopAlert; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index 092851cd..2483826f 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -47,6 +47,7 @@ NSString * const KeyActionTypeAlert = @"alert"; NSString * const KeyActionTypeTopAlert = @"topAlert"; NSString * const KeyActionTypeCollapseNotification = @"collapseNotification"; +NSString * const KeyActionTypeTopNotification = @"topNotification"; NSString * const KeyTopAlert = @"TopNotification"; #pragma mark - Values From 8a84d42c951d749ad6fc19bf5d2b963af2870197 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Mon, 4 Jan 2021 22:19:14 +0530 Subject: [PATCH 2/3] review comments updated --- .../Actions/ActionTopNotificationModel.swift | 2 +- .../OtherHandlers/MVMCoreUIActionHandler.h | 3 ++ .../OtherHandlers/MVMCoreUIActionHandler.m | 33 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift index c1c362c5..7ca1d6aa 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift @@ -12,7 +12,7 @@ import UIKit public static var identifier: String = "topNotification" public var actionType: String = ActionTopNotificationModel.identifier - public var topNotification: TopNotificationModel? + public var topNotification: TopNotificationModel public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index b18a2249..f6b89806 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -35,6 +35,9 @@ NS_ASSUME_NONNULL_BEGIN // Shows a top alert - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; +// Shows a molecular top alert +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; + // Collapses the current top notification - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index bafdd418..dee4c547 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -98,13 +98,8 @@ } }]; } else { - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; } } @@ -117,9 +112,8 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { //Handle molecular topnotification - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; + if (actionInformation) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; } } @@ -147,6 +141,9 @@ } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { [self collapseNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; return YES; + } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { + [self topNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; + return YES; } return NO; } @@ -186,13 +183,8 @@ } }]; } else { - NSDictionary *topNotification = [actionInformation dict:@"topNotification"]; - if (topNotification) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:topNotification]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; } } @@ -203,4 +195,11 @@ } } +- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + //Handle molecular topnotification + if (actionInformation) { + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; + } +} + @end From edc6296ff7666b00ec84a9c4d446efa1a9805203 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 4 Jan 2021 13:55:44 -0500 Subject: [PATCH 3/3] proper revert --- .../Atomic/Actions/ActionTopAlertModel.swift | 2 +- .../OtherHandlers/MVMCoreUIActionHandler.m | 60 +++++++------------ 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 0fb9d00d..62e496c2 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -12,7 +12,7 @@ import Foundation public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier - public var pageType: String? + public var pageType: String public var extraParameters: JSONValueDictionary? public var analyticsData: JSONValueDictionary? diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index dee4c547..79f92990 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -84,23 +84,18 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation string:KeyPageType]; - if (pageTypeForTopAlert) { - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; - } - [alertObject showAlert]; + NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; + if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; } - }]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } + [alertObject showAlert]; + } + }]; } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -112,9 +107,7 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { //Handle molecular topnotification - if (actionInformation) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; - } + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; } - (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { @@ -170,22 +163,17 @@ - (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { // Perform a top alert. NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - if (pageTypeForTopAlert) { - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; - if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; - } - [alertObject showAlert]; + [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { + + NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; + if (responseInfo) { + MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; + if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; } - }]; - } else { - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeParsingJSON domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegate class]),KeyActionTypeTopAlert]]; - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } + [alertObject showAlert]; + } + }]; } - (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { @@ -197,9 +185,7 @@ - (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { //Handle molecular topnotification - if (actionInformation) { - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dictionaryForKey:@"topNotification"]]; - } + [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; } @end