Digital PCT32 defect CXTDT-544924 - Insert missing OpenUrlOptionsModel handling.

This commit is contained in:
Hedden, Kyle Matthew 2024-04-16 18:02:53 -04:00
parent f6f272f727
commit c4b6122d4c

View File

@ -54,9 +54,9 @@ open class ActionOpenUrlHandler: MVMCoreJSONActionHandlerProtocol {
/// Opens the url using UIApplication open(url:). Throws URLError.failedToOpen if it fails. /// Opens the url using UIApplication open(url:). Throws URLError.failedToOpen if it fails.
@MainActor @MainActor
public static func open(url: URL) async throws { public static func open(url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:]) async throws {
try await withCheckedThrowingContinuation { continuation in try await withCheckedThrowingContinuation { continuation in
UIApplication.shared.open(url, options: [:]) { successful in UIApplication.shared.open(url, options: options) { successful in
if successful { if successful {
continuation.resume() continuation.resume()
} else { } else {
@ -76,12 +76,13 @@ open class ActionOpenUrlHandler: MVMCoreJSONActionHandlerProtocol {
// Try loading the app url first, otherwise fall back to browser url. // Try loading the app url first, otherwise fall back to browser url.
if let appURL = model.appURL { if let appURL = model.appURL {
do { do {
try await ActionOpenUrlHandler.open(url: appURL) try await ActionOpenUrlHandler.open(url: appURL, options: model.appURLOptions?.options ?? [:])
return return
} catch { } catch {
// Log error and continue // Log error and continue
MVMCoreLoggingHandler.shared()?.handleDebugMessage("Failed to open app url: \(appURL)") MVMCoreLoggingHandler.shared()?.handleDebugMessage("Failed to open app url: \(appURL)")
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType)) { let isUsingUniversalLinksOnly = model.appURLOptions?.options[.universalLinksOnly] as? Bool ?? false
if !isUsingUniversalLinksOnly , let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType)) {
MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject) MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject)
} }
} }