Merge branch 'feature/sms_action' into 'develop'
Sms action See merge request BPHV_MIPS/mvm_core!153
This commit is contained in:
commit
28ec7a408f
@ -34,6 +34,7 @@
|
||||
01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; };
|
||||
01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; };
|
||||
0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; };
|
||||
0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */; };
|
||||
0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; };
|
||||
30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; };
|
||||
@ -168,6 +169,7 @@
|
||||
0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||
0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = "<group>"; };
|
||||
0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = "<group>"; };
|
||||
0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = "<group>"; };
|
||||
30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = "<group>"; };
|
||||
30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionTimeHandler.m; sourceTree = "<group>"; };
|
||||
@ -449,6 +451,7 @@
|
||||
94C014D824212360005811A9 /* ActionSettingModel.swift */,
|
||||
BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */,
|
||||
D27073B625BB45C4001C7246 /* ActionActionsModel.swift */,
|
||||
0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */,
|
||||
);
|
||||
path = ActionType;
|
||||
sourceTree = "<group>";
|
||||
@ -889,6 +892,7 @@
|
||||
016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */,
|
||||
D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */,
|
||||
AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */,
|
||||
0AEBB84625FA75C000EA80EE /* ActionOpenSMSModel.swift in Sources */,
|
||||
016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */,
|
||||
8876D5F31FB50AB000EB2E3D /* UIFont+MFSpacing.m in Sources */,
|
||||
D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */,
|
||||
|
||||
@ -50,6 +50,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen;
|
||||
/// Goes back
|
||||
- (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
/// Opens Text Message
|
||||
- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
/// Makes a phone call
|
||||
- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;
|
||||
|
||||
|
||||
@ -69,9 +69,12 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
} else if ([actionType isEqualToString:KeyActionTypeCall]) {
|
||||
[self callAction:actionInformation additionalData:additionalData delegateObject:delegateObject];
|
||||
|
||||
} else if ([actionType isEqualToString:KeyActionTypeSMS]) {
|
||||
[self smsAction: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];
|
||||
|
||||
@ -83,7 +86,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];
|
||||
@ -99,7 +102,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
completionHandler(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (showLoadingOverlay) {
|
||||
[[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading];
|
||||
}
|
||||
@ -112,22 +115,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();
|
||||
@ -155,14 +158,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:)]) {
|
||||
@ -253,6 +256,14 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
|
||||
|
||||
NSString *phoneNumber = [actionInformation stringForKey:@"phoneNumber"];
|
||||
NSString *message = [actionInformation stringForKey:KeyMessage];
|
||||
NSString *smsQuery = [NSString stringWithFormat:@"sms:%@&body=%@", phoneNumber, message];
|
||||
[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];
|
||||
@ -333,33 +344,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
|
||||
@ -423,13 +434,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];
|
||||
}];
|
||||
|
||||
@ -34,6 +34,7 @@ extern NSString * const KeyActionTypeBack;
|
||||
extern NSString * const KeyActionTypeShare;
|
||||
extern NSString * const KeyShareType;
|
||||
extern NSString * const KeyShareText;
|
||||
extern NSString * const KeyActionTypeSMS;
|
||||
extern NSString * const KeyActionTypeCall;
|
||||
extern NSString * const KeyActionTypePreviousSubmit;
|
||||
extern NSString * const KeyActionTypeCancel;
|
||||
@ -45,6 +46,7 @@ extern NSString * const KeyActionInformation;
|
||||
extern NSString * const KeyLinkAwayAppURL;
|
||||
extern NSString * const KeyLinkAwayURL;
|
||||
extern NSString * const KeyCallNumber;
|
||||
extern NSString * const KeyPhoneNumber;
|
||||
extern NSString * const KeyPresentationStyle;
|
||||
extern NSString * const KeyExtraParameters;
|
||||
extern NSString * const KeyContextRoot;
|
||||
|
||||
@ -35,6 +35,7 @@ NSString * const KeyActionTypeRestart = @"restart";
|
||||
NSString * const KeyActionTypeBack = @"back";
|
||||
NSString * const KeyActionTypeShare = @"share";
|
||||
NSString * const KeyActionTypeCall = @"call";
|
||||
NSString * const KeyActionTypeSMS = @"sms";
|
||||
NSString * const KeyActionTypePreviousSubmit = @"previousSubmit";
|
||||
NSString * const KeyActionTypeCancel = @"cancel";
|
||||
NSString * const KeyActionTypeRedirect = @"switchApp";
|
||||
@ -45,6 +46,7 @@ NSString * const KeyActionInformation = @"actionInformation";
|
||||
NSString * const KeyLinkAwayAppURL = @"appURL";
|
||||
NSString * const KeyLinkAwayURL = @"browserUrl";
|
||||
NSString * const KeyCallNumber = @"callNumber";
|
||||
NSString * const KeyPhoneNumber = @"phoneNumber";
|
||||
NSString * const KeyPresentationStyle = @"presentationStyle";
|
||||
NSString * const KeyExtraParameters = @"extraParameters";
|
||||
NSString * const KeyContextRoot = @"appContext";
|
||||
|
||||
33
MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift
Normal file
33
MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// ActionOpenSMSModel.swift
|
||||
// MVMCore
|
||||
//
|
||||
// Created by Kevin Christiano on 3/11/21.
|
||||
// Copyright © 2021 myverizon. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
@objcMembers public class ActionOpenSMSModel: ActionModelProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier: String = "sms"
|
||||
public var actionType: String = ActionCallModel.identifier
|
||||
|
||||
public var phoneNumber: String
|
||||
public var message: String?
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(phoneNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
self.phoneNumber = phoneNumber
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,5 +22,7 @@
|
||||
try? ModelRegistry.register(ActionSettingModel.self)
|
||||
try? ModelRegistry.register(ActionNoopModel.self)
|
||||
try? ModelRegistry.register(ActionActionsModel.self)
|
||||
try? ModelRegistry.register(ActionOpenSMSModel.self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user