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?