From 52f0b1a1df964c1c34a6cc9cf08d7976b111670e Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 22 Apr 2025 15:39:35 +1000 Subject: [PATCH 1/4] Remove long-unused Iterable deep links handling See pbMoDN-fd-p2#comment-7311 --- Sources/Reader/Reader.entitlements | 1 - .../Classes/System/WordPressAppDelegate.swift | 19 +++++-------------- WordPress/Jetpack/JetpackDebug.entitlements | 1 - .../Jetpack/JetpackRelease-Alpha.entitlements | 1 - WordPress/Jetpack/JetpackRelease.entitlements | 1 - WordPress/WordPress-Alpha.entitlements | 1 - WordPress/WordPress.entitlements | 1 - 7 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Sources/Reader/Reader.entitlements b/Sources/Reader/Reader.entitlements index f88a631916f2..c040628806ec 100644 --- a/Sources/Reader/Reader.entitlements +++ b/Sources/Reader/Reader.entitlements @@ -6,7 +6,6 @@ webcredentials:wordpress.com webcredentials:*.wordpress.com - applinks:links.wp.a8cmail.com aps-environment development diff --git a/WordPress/Classes/System/WordPressAppDelegate.swift b/WordPress/Classes/System/WordPressAppDelegate.swift index 860924442a6f..952b31147935 100644 --- a/WordPress/Classes/System/WordPressAppDelegate.swift +++ b/WordPress/Classes/System/WordPressAppDelegate.swift @@ -473,24 +473,15 @@ extension WordPressAppDelegate { extension WordPressAppDelegate { private func trackDeepLink(for url: URL, completion: @escaping ((URL) -> Void)) { - guard isIterableDeepLink(url) else { - completion(url) - return - } - - let task = URLSession.shared.dataTask(with: url) {(_, response, error) in - if let url = response?.url { - completion(url) + let task = URLSession.shared.dataTask(with: url) { _, response, error in + guard let url = response?.url else { + return } + + completion(url) } task.resume() } - - private func isIterableDeepLink(_ url: URL) -> Bool { - return url.absoluteString.contains(WordPressAppDelegate.iterableDomain) - } - - private static let iterableDomain = "links.wp.a8cmail.com" } // MARK: - Helpers diff --git a/WordPress/Jetpack/JetpackDebug.entitlements b/WordPress/Jetpack/JetpackDebug.entitlements index 7300f805fe0e..11eb0930bd31 100644 --- a/WordPress/Jetpack/JetpackDebug.entitlements +++ b/WordPress/Jetpack/JetpackDebug.entitlements @@ -17,7 +17,6 @@ applinks:wordpress.com applinks:*.wordpress.com applinks:public-api.wordpress.com - applinks:links.wp.a8cmail.com com.apple.security.application-groups diff --git a/WordPress/Jetpack/JetpackRelease-Alpha.entitlements b/WordPress/Jetpack/JetpackRelease-Alpha.entitlements index efdce8fda2ba..486afcb0595c 100644 --- a/WordPress/Jetpack/JetpackRelease-Alpha.entitlements +++ b/WordPress/Jetpack/JetpackRelease-Alpha.entitlements @@ -13,7 +13,6 @@ applinks:wordpress.com applinks:*.wordpress.com applinks:public-api.wordpress.com - applinks:links.wp.a8cmail.com com.apple.security.application-groups diff --git a/WordPress/Jetpack/JetpackRelease.entitlements b/WordPress/Jetpack/JetpackRelease.entitlements index 7300f805fe0e..11eb0930bd31 100644 --- a/WordPress/Jetpack/JetpackRelease.entitlements +++ b/WordPress/Jetpack/JetpackRelease.entitlements @@ -17,7 +17,6 @@ applinks:wordpress.com applinks:*.wordpress.com applinks:public-api.wordpress.com - applinks:links.wp.a8cmail.com com.apple.security.application-groups diff --git a/WordPress/WordPress-Alpha.entitlements b/WordPress/WordPress-Alpha.entitlements index b4fdb57dfdfd..746c03fe2ddc 100644 --- a/WordPress/WordPress-Alpha.entitlements +++ b/WordPress/WordPress-Alpha.entitlements @@ -6,7 +6,6 @@ webcredentials:wordpress.com webcredentials:*.wordpress.com - applinks:links.wp.a8cmail.com com.apple.security.application-groups diff --git a/WordPress/WordPress.entitlements b/WordPress/WordPress.entitlements index a0ac3a4d6d3b..01c82000c649 100644 --- a/WordPress/WordPress.entitlements +++ b/WordPress/WordPress.entitlements @@ -12,7 +12,6 @@ webcredentials:wordpress.com webcredentials:*.wordpress.com - applinks:links.wp.a8cmail.com com.apple.developer.icloud-container-identifiers From dc2705dc5e3409e42eeb80447f25adc1230ef3cd Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 22 Apr 2025 16:02:09 +1000 Subject: [PATCH 2/4] Address main-thread sanitizer issue: change tab bar index on main thread --- .../Root View/WPTabBarController+RootViewPresenter.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift b/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift index 75f4b480f037..928f163069c3 100644 --- a/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift +++ b/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift @@ -22,8 +22,13 @@ extension WPTabBarController: RootViewPresenter { } func showNotificationsTab(completion: ((NotificationsViewController) -> Void)?) { - self.selectedIndex = WPTab.notifications.rawValue - completion?(self.notificationsViewController!) + // UITabBarController.selectedIndex must be used from main thread only. + DispatchQueue.main.async { [weak self] in + guard let self else { return } + + self.selectedIndex = WPTab.notifications.rawValue + completion?(self.notificationsViewController!) + } } // MARK: Me From a76a56971cf66c652fa840894ed7ad9bacc2a54f Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 16 May 2025 10:32:08 +1000 Subject: [PATCH 3/4] Push main queue dispatch from show notifications to deep link handler See comment here https://github.com/wordpress-mobile/WordPress-iOS/pull/24487/files#r2053393420 --- .../Root View/WPTabBarController+RootViewPresenter.swift | 9 ++++----- WordPress/Classes/System/WordPressAppDelegate.swift | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift b/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift index 928f163069c3..d0ead2d6380c 100644 --- a/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift +++ b/WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift @@ -1,4 +1,5 @@ import UIKit +import WordPressShared /// `WPTabBarController` is used as the root presenter when Jetpack features are enabled /// and the app's UI is normal. @@ -23,12 +24,10 @@ extension WPTabBarController: RootViewPresenter { func showNotificationsTab(completion: ((NotificationsViewController) -> Void)?) { // UITabBarController.selectedIndex must be used from main thread only. - DispatchQueue.main.async { [weak self] in - guard let self else { return } + wpAssert(Thread.isMainThread) - self.selectedIndex = WPTab.notifications.rawValue - completion?(self.notificationsViewController!) - } + selectedIndex = WPTab.notifications.rawValue + completion?(notificationsViewController!) } // MARK: Me diff --git a/WordPress/Classes/System/WordPressAppDelegate.swift b/WordPress/Classes/System/WordPressAppDelegate.swift index 952b31147935..f55b19904b53 100644 --- a/WordPress/Classes/System/WordPressAppDelegate.swift +++ b/WordPress/Classes/System/WordPressAppDelegate.swift @@ -457,7 +457,9 @@ extension WordPressAppDelegate { } trackDeepLink(for: url) { url in - UniversalLinkRouter.shared.handle(url: url) + DispatchQueue.main.async { + UniversalLinkRouter.shared.handle(url: url) + } } } From e4b5163251b416187cd018ace7b07e005d4e6026 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 16 May 2025 10:45:29 +1000 Subject: [PATCH 4/4] Add assertion failure for deep link without URL --- WordPress/Classes/System/WordPressAppDelegate.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/Classes/System/WordPressAppDelegate.swift b/WordPress/Classes/System/WordPressAppDelegate.swift index f55b19904b53..a835065107c4 100644 --- a/WordPress/Classes/System/WordPressAppDelegate.swift +++ b/WordPress/Classes/System/WordPressAppDelegate.swift @@ -477,6 +477,10 @@ extension WordPressAppDelegate { private func trackDeepLink(for url: URL, completion: @escaping ((URL) -> Void)) { let task = URLSession.shared.dataTask(with: url) { _, response, error in guard let url = response?.url else { + wpAssertionFailure( + "Received a deep link response without URL attached.", + userInfo: ["response": response ?? "no response"] + ) return }