From df948c9c2a7e1a9004b36bc15dcdc7ccdf8eec60 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Thu, 19 Dec 2024 20:28:00 +0100 Subject: [PATCH] Fix sharing via the Share & Action extensions on iOS 18 (#3745) Task/Issue URL: https://app.asana.com/0/414709148257752/1208991975879543/f Tech Design URL: CC: **Description**: Fixes sharing to the DDG app from the share + action extensions on iOS 18 --- OpenAction/ActionViewController.swift | 13 ++++++++++--- ShareExtension/ShareViewController.swift | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/OpenAction/ActionViewController.swift b/OpenAction/ActionViewController.swift index 2a4c493ebf..afe78b94a4 100644 --- a/OpenAction/ActionViewController.swift +++ b/OpenAction/ActionViewController.swift @@ -64,9 +64,16 @@ class ActionViewController: UIViewController { var responder = self as UIResponder? let selectorOpenURL = sel_registerName("openURL:") while let current = responder { - if current.responds(to: selectorOpenURL) { - current.perform(selectorOpenURL, with: url, afterDelay: 0) - break + if #available(iOS 18.0, *) { + if let application = current as? UIApplication { + application.open(url, options: [:], completionHandler: nil) + break + } + } else { + if current.responds(to: selectorOpenURL) { + current.perform(selectorOpenURL, with: url, afterDelay: 0) + break + } } responder = current.next } diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index 98829b4cbe..5afada430c 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -84,9 +84,16 @@ class ShareViewController: SLComposeServiceViewController { let deepLink = URL(string: AppDeepLinkSchemes.quickLink.appending(url.absoluteString))! var responder = self as UIResponder? while responder != nil { - if responder!.responds(to: selector) { - _ = responder?.perform(selector, with: deepLink, with: {}) - break + if #available(iOS 18.0, *) { + if let application = responder as? UIApplication { + application.open(deepLink, options: [:], completionHandler: nil) + break + } + } else { + if responder!.responds(to: selector) { + _ = responder?.perform(selector, with: deepLink, with: {}) + break + } } responder = responder!.next }