diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 449ae7c..fe05d49 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -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 */; }; @@ -167,6 +168,7 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSModel.swift; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionTimeHandler.m; sourceTree = ""; }; @@ -446,6 +448,7 @@ 94C014D824212360005811A9 /* ActionSettingModel.swift */, BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, ); path = ActionType; sourceTree = ""; @@ -885,6 +888,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 */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 2f41e93..14930a2 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -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; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index ddb1fab..295d393 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -69,6 +69,9 @@ 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]; @@ -261,6 +264,17 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } +/// Send Text Message +- (void)smsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + + 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]; + [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]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index c2d7f8e..907feed 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -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; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 80317ea..a678877 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -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"; diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift new file mode 100644 index 0000000..33fed5e --- /dev/null +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift @@ -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 + // TODO: decode into phone number once action handler is re-written + public var callNumber: String + public var message: String? + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(callNumber: String, message: String?, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.callNumber = callNumber + self.message = message + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 6c3df04..f13e3e8 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -6,7 +6,6 @@ // Copyright © 2019 myverizon. All rights reserved. // -import Foundation @objcMembers public class ModelMapping: NSObject { @@ -22,5 +21,6 @@ import Foundation try? ModelRegistry.register(ActionSettingModel.self) try? ModelRegistry.register(ActionNoopModel.self) try? ModelRegistry.register(ActionActionsModel.self) + try? ModelRegistry.register(ActionOpenSMSModel.self) } }