latest updates for fios additions.
This commit is contained in:
parent
f595e40f2f
commit
d4dfe2567b
@ -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<NSString *,id> * _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<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();
|
||||
@ -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];
|
||||
}];
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -35,11 +35,11 @@ public protocol ModelProtocol: Codable {
|
||||
extension ModelProtocol {
|
||||
|
||||
static public func decode<K: CodingKey>(keyedContainer: KeyedDecodingContainer<K>, 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<K: CodingKey>(keyedContainer: inout KeyedEncodingContainer<K>, codingKey: K) throws {
|
||||
@ -50,4 +50,3 @@ extension ModelProtocol {
|
||||
try unkeyedContainer.encode(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user