diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 394e10b..73291ae 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -92,6 +92,17 @@ AF43A7411FC5FA6F008E9347 /* MVMCoreViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A74C1FC6109F008E9347 /* MVMCoreSessionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A74A1FC6109F008E9347 /* MVMCoreSessionObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A74B1FC6109F008E9347 /* MVMCoreSessionObject.m */; }; + AF69D4E9286E54D500BC6862 /* ActionCallHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4E8286E54D500BC6862 /* ActionCallHandler.swift */; }; + AF69D4EB286E586200BC6862 /* ActionRestartHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4EA286E586200BC6862 /* ActionRestartHandler.swift */; }; + AF69D4ED286E5D8C00BC6862 /* ActionCancelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4EC286E5D8C00BC6862 /* ActionCancelHandler.swift */; }; + AF69D4EF286E612800BC6862 /* ActionOpenSMSHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4EE286E612800BC6862 /* ActionOpenSMSHandler.swift */; }; + AF69D4F1286E9D8000BC6862 /* ActionNoopHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4F0286E9D8000BC6862 /* ActionNoopHandler.swift */; }; + AF69D4F3286E9DCE00BC6862 /* ActionActionsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4F2286E9DCE00BC6862 /* ActionActionsHandler.swift */; }; + AF69D4F5286E9F5900BC6862 /* ActionSettingHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4F4286E9F5900BC6862 /* ActionSettingHandler.swift */; }; + AF69D4F7286EA0B800BC6862 /* ActionPreviousSubmitHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4F6286EA0B800BC6862 /* ActionPreviousSubmitHandler.swift */; }; + AF69D4F9286EA27400BC6862 /* ActionRedirectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4F8286EA27400BC6862 /* ActionRedirectModel.swift */; }; + AF69D4FB286EA29300BC6862 /* ActionRedirectHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF69D4FA286EA29300BC6862 /* ActionRedirectHandler.swift */; }; + AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF787412286DEF8B00670588 /* ActionBackHandler.swift */; }; AF8D13392774EA1D008AF4A9 /* ActionOpenUrlHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */; }; AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */; }; @@ -242,6 +253,17 @@ AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewProtocol.h; sourceTree = ""; }; AF43A74A1FC6109F008E9347 /* MVMCoreSessionObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionObject.h; sourceTree = ""; }; AF43A74B1FC6109F008E9347 /* MVMCoreSessionObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionObject.m; sourceTree = ""; }; + AF69D4E8286E54D500BC6862 /* ActionCallHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCallHandler.swift; sourceTree = ""; }; + AF69D4EA286E586200BC6862 /* ActionRestartHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionRestartHandler.swift; sourceTree = ""; }; + AF69D4EC286E5D8C00BC6862 /* ActionCancelHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCancelHandler.swift; sourceTree = ""; }; + AF69D4EE286E612800BC6862 /* ActionOpenSMSHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenSMSHandler.swift; sourceTree = ""; }; + AF69D4F0286E9D8000BC6862 /* ActionNoopHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNoopHandler.swift; sourceTree = ""; }; + AF69D4F2286E9DCE00BC6862 /* ActionActionsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionActionsHandler.swift; sourceTree = ""; }; + AF69D4F4286E9F5900BC6862 /* ActionSettingHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionSettingHandler.swift; sourceTree = ""; }; + AF69D4F6286EA0B800BC6862 /* ActionPreviousSubmitHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPreviousSubmitHandler.swift; sourceTree = ""; }; + AF69D4F8286EA27400BC6862 /* ActionRedirectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionRedirectModel.swift; sourceTree = ""; }; + AF69D4FA286EA29300BC6862 /* ActionRedirectHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionRedirectHandler.swift; sourceTree = ""; }; + AF787412286DEF8B00670588 /* ActionBackHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackHandler.swift; sourceTree = ""; }; AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlHandler.swift; sourceTree = ""; }; AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreErrorConstants.h; sourceTree = ""; }; AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreErrorConstants.m; sourceTree = ""; }; @@ -464,16 +486,7 @@ 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */, 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, 01DB1F2A26444F7F000F1AF4 /* ActionOpenPageProtocol.swift */, - 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, - 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */, - 94C014D024211869005811A9 /* ActionRestartModel.swift */, - 94C014D2242119E6005811A9 /* ActionPreviousSubmitModel.swift */, - 94C014D424211AF0005811A9 /* ActionCancelModel.swift */, - 94C014D824212360005811A9 /* ActionSettingModel.swift */, - BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, - D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, - 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, 0ACC81A12613C73800A9C886 /* ActionContactModel.swift */, ); path = ActionType; @@ -626,6 +639,26 @@ AF130B8D2788DF6E00C6C03C /* OpenURLOptionsModel.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */, + 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, + AF787412286DEF8B00670588 /* ActionBackHandler.swift */, + 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, + AF69D4E8286E54D500BC6862 /* ActionCallHandler.swift */, + 94C014D024211869005811A9 /* ActionRestartModel.swift */, + AF69D4EA286E586200BC6862 /* ActionRestartHandler.swift */, + 94C014D424211AF0005811A9 /* ActionCancelModel.swift */, + AF69D4EC286E5D8C00BC6862 /* ActionCancelHandler.swift */, + 0AEBB84525FA75C000EA80EE /* ActionOpenSMSModel.swift */, + AF69D4EE286E612800BC6862 /* ActionOpenSMSHandler.swift */, + BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, + AF69D4F0286E9D8000BC6862 /* ActionNoopHandler.swift */, + D27073B625BB45C4001C7246 /* ActionActionsModel.swift */, + AF69D4F2286E9DCE00BC6862 /* ActionActionsHandler.swift */, + 94C014D824212360005811A9 /* ActionSettingModel.swift */, + AF69D4F4286E9F5900BC6862 /* ActionSettingHandler.swift */, + 94C014D2242119E6005811A9 /* ActionPreviousSubmitModel.swift */, + AF69D4F6286EA0B800BC6862 /* ActionPreviousSubmitHandler.swift */, + AF69D4F8286EA27400BC6862 /* ActionRedirectModel.swift */, + AF69D4FA286EA29300BC6862 /* ActionRedirectHandler.swift */, ); path = ActionHandling; sourceTree = ""; @@ -843,7 +876,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.framework\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH}/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -a \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; + shellScript = "unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode\n\n# define output folder environment variable\nC_PROJECT_NAME=\"MVMCore\"\nPHONE_CONFIGURATION=\"Release\"\nSIMULATOR_CONFIGURATION=\"Debug\"\nSIMULATOR_LIBRARY_PATH=\"${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}\"\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/universal\n\nxcodebuild archive \\\n -scheme \"${C_PROJECT_NAME}\" \\\n -configuration ${PHONE_CONFIGURATION} \\\n -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" \\\n -sdk iphoneos \\\n -destination 'generic/platform=iOS' \\\n SKIP_INSTALL=NO\n \n exit 0\n\nxcodebuild archive \\\n -scheme \"${C_PROJECT_NAME}\" \\\n -configuration ${SIMULATOR_CONFIGURATION} \\\n -archivePath \"${SIMULATOR_LIBRARY_PATH}\" \\\n -sdk iphonesimulator \\\n -destination 'generic/platform=iOS Simulator' \\\n SKIP_INSTALL=NO\n\n\n\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -scheme \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${PHONE_CONFIGURATION} -sdk iphoneos -archivePath \"${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}\" archive SKIP_INSTALL=false\n\nxcodebuild -target \"${C_PROJECT_NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${SIMULATOR_CONFIGURATION} -sdk iphonesimulator -arch x86_64 BUILD_DIR=\"${BUILD_DIR}\" ALWAYS_SEARCH_USER_PATHS=true\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\nrm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework\ncp -R ${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/\"${C_PROJECT_NAME}\".xcarchive/Products/Library/Frameworks/${C_PROJECT_NAME}.framework ${UNIVERSAL_OUTPUTFOLDER}\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\" \"${SIMULATOR_LIBRARY_PATH}/${C_PROJECT_NAME}\"\n\nmv ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME} ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/${C_PROJECT_NAME}\n\n# For Swift framework, Swiftmodule needs to be copied in the universal framework\nif [ -d \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" ]; then\ncp -a \"${SIMULATOR_LIBRARY_PATH}/Modules/${C_PROJECT_NAME}.swiftmodule/\" \"${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.framework/Modules/${C_PROJECT_NAME}.swiftmodule/\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -852,12 +885,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AF69D4ED286E5D8C00BC6862 /* ActionCancelHandler.swift in Sources */, AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */, 946EE1A7237B5B1C0036751F /* ModelRegistry.swift in Sources */, AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */, AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */, AF8D13392774EA1D008AF4A9 /* ActionOpenUrlHandler.swift in Sources */, AF130B8E2788DF6E00C6C03C /* OpenURLOptionsModel.swift in Sources */, + AF69D4EB286E586200BC6862 /* ActionRestartHandler.swift in Sources */, AFBB968E1FBA3A9A0008D868 /* MVMCoreNavigationHandler.m in Sources */, BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */, D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */, @@ -876,6 +911,7 @@ AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */, 1DAD0FFE26AAB40000216E83 /* ActionRunJavaScriptModel.swift in Sources */, 946EE1AB237B5C940036751F /* Decoder.swift in Sources */, + AF69D4F3286E9DCE00BC6862 /* ActionActionsHandler.swift in Sources */, 946EE1BC237B691A0036751F /* ActionOpenPageModel.swift in Sources */, 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */, 881D26931FCC9D180079C521 /* MVMCoreErrorObject.m in Sources */, @@ -885,27 +921,33 @@ 30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */, D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */, 94C014D3242119E6005811A9 /* ActionPreviousSubmitModel.swift in Sources */, + AF69D4FB286EA29300BC6862 /* ActionRedirectHandler.swift in Sources */, 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, D27073B725BB45C4001C7246 /* ActionActionsModel.swift in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, 0ACC81A22613C73800A9C886 /* ActionContactModel.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, + AF69D4EF286E612800BC6862 /* ActionOpenSMSHandler.swift in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */, 8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */, 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */, 01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */, + AF69D4E9286E54D500BC6862 /* ActionCallHandler.swift in Sources */, AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */, AFED77A61FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.m in Sources */, 016CF36925FA6DD400B82A1F /* ClientParameterHandler.swift in Sources */, + AF69D4F7286EA0B800BC6862 /* ActionPreviousSubmitHandler.swift in Sources */, AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */, 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */, AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */, + AF69D4F5286E9F5900BC6862 /* ActionSettingHandler.swift in Sources */, D27073CD25BB4CEF001C7246 /* MVMCoreActionHandler+Extension.swift in Sources */, 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */, 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */, + AF69D4F9286EA27400BC6862 /* ActionRedirectModel.swift in Sources */, AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */, AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */, 94C014D924212360005811A9 /* ActionSettingModel.swift in Sources */, @@ -923,10 +965,12 @@ D27073D125BB844B001C7246 /* MVMCoreActionDelegateProtocol+Extension.swift in Sources */, AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */, AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */, + AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */, 946EE1B4237B619D0036751F /* Encoder.swift in Sources */, AFBB96941FBA3A9A0008D868 /* MVMCorePresentAnimationOperation.m in Sources */, 94C014D524211AF0005811A9 /* ActionCancelModel.swift in Sources */, AF43A5841FBB66DE008E9347 /* MVMCoreConstants.m in Sources */, + AF69D4F1286E9D8000BC6862 /* ActionNoopHandler.swift in Sources */, 016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */, D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */, AFBB966A1FBA3A570008D868 /* MVMCoreLoadRequestOperation.m in Sources */, @@ -994,7 +1038,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1011,7 +1054,6 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1056,7 +1098,6 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1094,7 +1135,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; MARKETING_VERSION = 2.0; - ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCore; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; diff --git a/MVMCore/MVMCore/ActionHandling/ActionActionsHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionActionsHandler.swift new file mode 100644 index 0000000..1e88940 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionActionsHandler.swift @@ -0,0 +1,25 @@ +// +// ActionActionsHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionActionsHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionActionsModel else { return } + for action in model.actions { + // TODO: Improve to make truly concurrent. + if model.concurrent { + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalData, delegateObject: delegateObject) + } else { + MVMCoreActionHandler.shared()?.syncHandleAction(with: action, additionalData: additionalData, delegateObject: delegateObject) + } + } + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift b/MVMCore/MVMCore/ActionHandling/ActionActionsModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionActionsModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionActionsModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift new file mode 100644 index 0000000..258a26a --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift @@ -0,0 +1,22 @@ +// +// ActionBackHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionBackHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionBackModel else { return } + do { + delegateObject?.actionDelegate?.handleBackAction?(try MVMCoreActionHandler.convertActionToJSON(model), additionalData: additionalData) ?? MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } catch { + MVMCoreActionHandler.shared()?.handle(error: error, model: model, delegateObject: delegateObject, additionalData: additionalData) + } + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift b/MVMCore/MVMCore/ActionHandling/ActionBackModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionBackModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionBackModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionCallHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionCallHandler.swift new file mode 100644 index 0000000..47730a4 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionCallHandler.swift @@ -0,0 +1,18 @@ +// +// ActionCallHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionCallHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionCallModel else { return } + MVMCoreActionUtility.linkAway("tel://\(model.actionType)", appURLString: nil) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift b/MVMCore/MVMCore/ActionHandling/ActionCallModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionCallModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionCallModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionCancelHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionCancelHandler.swift new file mode 100644 index 0000000..d52885c --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionCancelHandler.swift @@ -0,0 +1,17 @@ +// +// ActionCancelHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionCancelHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + delegateObject?.actionDelegate?.handleCancel?(model.toJSON(), additionalData: additionalData) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift b/MVMCore/MVMCore/ActionHandling/ActionCancelModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionCancelModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionCancelModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionNoopHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionNoopHandler.swift new file mode 100644 index 0000000..ac3af3e --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionNoopHandler.swift @@ -0,0 +1,15 @@ +// +// ActionNoopHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionNoopHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) {} +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionNoopModel.swift b/MVMCore/MVMCore/ActionHandling/ActionNoopModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionNoopModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionNoopModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionOpenSMSHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionOpenSMSHandler.swift new file mode 100644 index 0000000..67aa4bd --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionOpenSMSHandler.swift @@ -0,0 +1,18 @@ +// +// ActionOpenSMSHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionOpenSMSHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionOpenSMSModel else { return } + MVMCoreActionUtility.linkAway("sms:\(model.phoneNumber)&body=\(model.message ?? "")".addingPercentEncoding(withAllowedCharacters: CharacterSet(charactersIn: "0123456789+-.")), appURLString: nil) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift b/MVMCore/MVMCore/ActionHandling/ActionOpenSMSModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionOpenSMSModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionOpenSMSModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionPreviousSubmitHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionPreviousSubmitHandler.swift new file mode 100644 index 0000000..e803ab7 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionPreviousSubmitHandler.swift @@ -0,0 +1,24 @@ +// +// ActionPreviousSubmitHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +/// Makes the previous request, needs the delegate for this +open class ActionPreviousSubmitHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionPreviousSubmitModel else { return } + let json = model.toJSON() + delegateObject?.actionDelegate?.prepareRequest?(forPreviousSubmission: json, additionalData: additionalData, submit: { requestParameters, dataForPage in + MVMCoreActionHandler.shared()?.updateRequestParameters(beforeHandleOpenPageAction: requestParameters, callBack: { requestParameters in + delegateObject?.actionDelegate?.handleOpenPage?(for: requestParameters, actionInformation: json, additionalData: dataForPage) ?? MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + }) + }) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift b/MVMCore/MVMCore/ActionHandling/ActionPreviousSubmitModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionPreviousSubmitModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionPreviousSubmitModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionRedirectHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionRedirectHandler.swift new file mode 100644 index 0000000..e890617 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionRedirectHandler.swift @@ -0,0 +1,18 @@ +// +// ActionRedirectHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionRedirectHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + // Have delegate redirect. + MVMCoreSessionObject.sharedGlobal()?.redirect(withInfo: model.toJSON()) + } +} diff --git a/MVMCore/MVMCore/ActionHandling/ActionRedirectModel.swift b/MVMCore/MVMCore/ActionHandling/ActionRedirectModel.swift new file mode 100644 index 0000000..d36722e --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionRedirectModel.swift @@ -0,0 +1,18 @@ +// +// ActionRedirectModel.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +@objcMembers public class ActionRedirectModel: ActionOpenPageModel { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public override class var identifier: String { KeyActionTypeRedirect } + public override var actionType: String { ActionRedirectModel.identifier } +} diff --git a/MVMCore/MVMCore/ActionHandling/ActionRestartHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionRestartHandler.swift new file mode 100644 index 0000000..c468fe6 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionRestartHandler.swift @@ -0,0 +1,28 @@ +// +// ActionRestartHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionRestartHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + guard let model = model as? ActionRestartModel else { return } + + // Invalidates the session before restarting. + MVMCoreSessionTimeHandler.sharedSession()?.invalidateSession({ error in + guard error?.code != NSURLErrorCancelled else { return } + if let error = error { + MVMCoreActionHandler.shared()?.handle(errorObject: error, model: model, delegateObject: delegateObject, additionalData: additionalData) + } else { + // Restarts the app (forcing any passed in page types). + MVMCoreSessionObject.sharedGlobal()?.restartSession(withPageType: model.pageType, parameters: model.extraParameters, clearAllVariables: true) + } + }) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift b/MVMCore/MVMCore/ActionHandling/ActionRestartModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionRestartModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionRestartModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/ActionSettingHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionSettingHandler.swift new file mode 100644 index 0000000..9d09408 --- /dev/null +++ b/MVMCore/MVMCore/ActionHandling/ActionSettingHandler.swift @@ -0,0 +1,17 @@ +// +// ActionSettingHandler.swift +// MVMCore +// +// Created by Scott Pfeil on 6/30/22. +// Copyright © 2022 myverizon. All rights reserved. +// + +import Foundation + +open class ActionSettingHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func handleAction(_ model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + MVMCoreActionUtility.linkAway(UIApplication.openSettingsURLString, appURLString: nil) + } +} diff --git a/MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift b/MVMCore/MVMCore/ActionHandling/ActionSettingModel.swift similarity index 100% rename from MVMCore/MVMCore/Models/ActionType/ActionSettingModel.swift rename to MVMCore/MVMCore/ActionHandling/ActionSettingModel.swift diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift index 1308ee5..ab572f8 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol+Extension.swift @@ -9,6 +9,12 @@ import Foundation public extension MVMCoreActionDelegateProtocol { + + /// Allows the delegate to cancel the action. + func shouldPerform(action: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) -> Bool { + return true + } + /// Handles any action errors. func handleAction(error: MVMCoreErrorObject, action: ActionModelProtocol, additionalData: [AnyHashable: Any]?) { MVMCoreActionHandler.shared()?.defaultHandleActionError(error, additionalData: additionalData) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift index 8b66d82..4160c61 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift @@ -16,19 +16,37 @@ public protocol MVMCoreActionHandlerProtocol: ModelHandlerProtocol { public extension MVMCoreActionHandler { /// Converts the action to json for old action handler to handle. - func convertActionToJSON(_ model: ActionModelProtocol, delegateObject: DelegateObject?) -> [AnyHashable: Any]? { - do { - let data = try model.encode() - guard let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [AnyHashable: Any] else { - throw ModelRegistry.Error.decoderError - } - return json - } catch { - if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") { - delegateObject?.actionDelegate?.handleAction(error: errorObject, action: model, additionalData: model.extraParameters) ?? MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: model.extraParameters) - } - return nil + static func convertActionToJSON(_ model: ActionModelProtocol) throws -> [AnyHashable: Any] { + let data = try model.encode() + guard let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [AnyHashable: Any] else { + throw ModelRegistry.Error.decoderError } + return json + } + + /// Creates a model from the action json. + static func createModel(with json: [AnyHashable: Any]) throws -> ActionModelProtocol { + guard let castedSelf = json as? [String: Any] else { + throw ModelRegistry.Error.decoderOther(message: "Dictionary is not of type [String: Any]") + } + guard let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self) else { + throw ModelRegistry.Error.decoderErrorModelNotMapped() + } + guard let actionModel = try actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else { + throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol") + } + return actionModel + } + + /// Converts the Error to an ErrorObject and calls handle(errorObject + func handle(error: Error, model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + guard let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType)) else { return } + handle(errorObject: errorObject, model: model, delegateObject: delegateObject, additionalData: additionalData) + } + + /// Handles the error by calling actionDelegate handleAction, else ActionHandler defaultHandleActionError. + func handle(errorObject: MVMCoreErrorObject, model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { + delegateObject?.actionDelegate?.handleAction(error: errorObject, action: model, additionalData: additionalData) ?? defaultHandleActionError(errorObject, additionalData: additionalData) } @objc func hasActionHandler(actionType: String?, actionInformation: [String: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Bool { @@ -68,14 +86,22 @@ public extension MVMCoreActionHandler { /// Start action on current thread. func syncHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { - guard let json = convertActionToJSON(model, delegateObject: delegateObject) else { return } - synchronouslyHandleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + do { + let json = try MVMCoreActionHandler.convertActionToJSON(model) + synchronouslyHandleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + } catch { + handle(error: error, model: model, delegateObject: delegateObject, additionalData: additionalData) + } } /// Start action on dispatched background thread. func asyncHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { - guard let json = convertActionToJSON(model, delegateObject: delegateObject) else { return } - handleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + do { + let json = try MVMCoreActionHandler.convertActionToJSON(model) + handleAction(model.actionType, actionInformation: json, additionalData: additionalData, delegateObject: delegateObject) + } catch { + handle(error: error, model: model, delegateObject: delegateObject, additionalData: additionalData) + } } @objc static func getErrorLocation(with delegate: MVMCoreActionDelegateProtocol?, actionType: String) -> String { diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 068b018..1854927 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -44,33 +44,9 @@ extern NSString * _Nonnull const KeyActionTypeOpen; /// Tries to open a page - (void)openPageAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -/// restarts the app -- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - /// 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; - -/// Makes the previous request, needs the delegate for this -- (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Redirects to another experience -- (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Cancels (like in a popup) -- (void)cancelAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Goes to settings app -- (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Performs multiple actions -- (void)actions:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - /// Subclass this to handle other custom actions. Return YES if handled, and NO if not. - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(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 cac409d..f3974f0 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -59,40 +59,13 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([actionType isEqualToString:KeyActionTypeOpen]) { [self openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeRestart]) { - [self restartAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeBack]) { - [self backAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } 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: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]; - - } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { - [self redirectAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeCancel]) { - [self cancelAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } 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]; } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) { // not a known action type. [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -227,44 +200,8 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - // Invalidates the session before restarting. - [[MVMCoreSessionTimeHandler sharedSessionHandler] invalidateSession:^(MVMCoreErrorObject * _Nullable error) { - - // Restarts the app (forcing any passed in page types). - if (error.code != NSURLErrorCancelled) { - - if (error) { - - // Error invalidating. - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else { - - // Restart the application with the page type. - NSString *pageType = [actionInformation string:KeyPageType]; - NSDictionary *parameters = [actionInformation dict:KeyExtraParameters]; - [[MVMCoreSessionObject sharedGlobal] restartSessionWithPageType:pageType parameters:parameters clearAllVariables:YES]; - } - } - }]; -} - - (void)backAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Go back. - if ([delegateObject.actionDelegate respondsToSelector:@selector(handleBackAction:additionalData:)]) { - [delegateObject.actionDelegate handleBackAction:actionInformation additionalData:additionalData]; - } else { - [[MVMCoreNavigationHandler sharedNavigationHandler] removeCurrentViewController]; - } -} - -- (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]; + [self handleActionWithDictionary:actionInformation ?: @{KeyActionType: KeyActionTypeBack} additionalData:additionalData delegateObject:delegateObject]; } - (void)contactAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { @@ -328,61 +265,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)callAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Call - NSString *callNumber = [actionInformation stringForKey:KeyCallNumber]; - [MVMCoreActionUtility linkAway:[@"tel://" stringByAppendingString:callNumber] appURLString:nil]; -} - -- (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform the previous submission. - __weak typeof(self) weakSelf = self; - if ([delegateObject.actionDelegate respondsToSelector:@selector(prepareRequestForPreviousSubmission:additionalData:submit:)]) { - [delegateObject.actionDelegate prepareRequestForPreviousSubmission:actionInformation additionalData:additionalData submit:^(MVMCoreRequestParameters * _Nonnull requestParameters, NSDictionary * _Nullable dataForPage) { - - [weakSelf updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) { - // Give the delegate a chance to alter the request parameters - if ([delegateObject.actionDelegate respondsToSelector:@selector(handleOpenPageForRequestParameters:actionInformation:additionalData:)]) { - [delegateObject.actionDelegate handleOpenPageForRequestParameters:requestParameters actionInformation:actionInformation additionalData:dataForPage]; - } else { - [MVMCoreActionHandler defaultHandleOpenPageForRequestParameters:requestParameters - actionInformation:actionInformation - additionalData:additionalData - delegateObject:delegateObject]; - } - }]; - }]; - } -} - -- (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Have delegate redirect. - [[MVMCoreSessionObject sharedGlobal] redirectWithInfo:actionInformation]; -} - -- (void)cancelAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - if ([delegateObject.actionDelegate respondsToSelector:@selector(handleCancel:additionalData:)]) { - [delegateObject.actionDelegate handleCancel:actionInformation additionalData:additionalData]; - } -} - -- (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; -} - -- (void)actions:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - NSArray *actions = [actionInformation array:@"actions"]; - BOOL concurrent = [actionInformation boolForKey:@"concurrent"]; - for (NSDictionary *action in actions) { - NSString *actionType = [action string:KeyActionType]; - if (concurrent) { - [self handleAction:actionType actionInformation:action additionalData:additionalData delegateObject:delegateObject]; - } else { - [self synchronouslyHandleAction:actionType actionInformation:action additionalData:additionalData delegateObject:delegateObject]; - } - } -} - - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { return [self hasActionHandlerWithActionType:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; } diff --git a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift index 184be57..a646ef7 100644 --- a/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/ActionOpenPageModel.swift @@ -12,8 +12,8 @@ // MARK: - Properties //-------------------------------------------------- - public static var identifier: String = "openPage" - public var actionType: String = ActionOpenPageModel.identifier + public class var identifier: String { "openPage" } + public var actionType: String { ActionOpenPageModel.identifier } public var pageType: String public var modules: [String]? public var baseURL: String? diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index da05419..605c7ff 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -14,16 +14,18 @@ ModelRegistry.register(ActionRunJavaScriptModel.self) ModelRegistry.register(ActionOpenPageModel.self) ModelRegistry.register(handler: ActionOpenUrlHandler.self, for: ActionOpenUrlModel.self) - ModelRegistry.register(ActionCallModel.self) - ModelRegistry.register(ActionBackModel.self) + ModelRegistry.register(handler: ActionCallHandler.self, for: ActionCallModel.self) + ModelRegistry.register(handler: ActionCallHandler.self, for: ActionCallModel.self) + ModelRegistry.register(handler: ActionBackHandler.self, for: ActionBackModel.self) ModelRegistry.register(ActionShareModel.self) - ModelRegistry.register(ActionRestartModel.self) - ModelRegistry.register(ActionPreviousSubmitModel.self) - ModelRegistry.register(ActionCancelModel.self) - ModelRegistry.register(ActionSettingModel.self) - ModelRegistry.register(ActionNoopModel.self) - ModelRegistry.register(ActionActionsModel.self) - ModelRegistry.register(ActionOpenSMSModel.self) + ModelRegistry.register(handler: ActionRestartHandler.self, for: ActionRestartModel.self) + ModelRegistry.register(handler: ActionRedirectHandler.self, for: ActionRedirectModel.self) + ModelRegistry.register(handler: ActionPreviousSubmitHandler.self, for: ActionPreviousSubmitModel.self) + ModelRegistry.register(handler: ActionCancelHandler.self, for: ActionCancelModel.self) + ModelRegistry.register(handler: ActionSettingHandler.self, for: ActionSettingModel.self) + ModelRegistry.register(handler: ActionNoopHandler.self, for: ActionNoopModel.self) + ModelRegistry.register(handler: ActionActionsHandler.self, for: ActionActionsModel.self) + ModelRegistry.register(handler: ActionOpenSMSHandler.self, for: ActionOpenSMSModel.self) ModelRegistry.register(ActionContactModel.self) } }