diff --git a/Modules/Sources/WordPressData/Swift/SearchableActivityConvertable.swift b/Modules/Sources/WordPressData/Swift/SearchableActivityConvertable.swift index 7f7132f7bc02..65d9ff9fc79e 100644 --- a/Modules/Sources/WordPressData/Swift/SearchableActivityConvertable.swift +++ b/Modules/Sources/WordPressData/Swift/SearchableActivityConvertable.swift @@ -1,7 +1,5 @@ import UIKit import CoreSpotlight -import Intents -import MobileCoreServices import UniformTypeIdentifiers /// Custom NSUSerActivity types for the WPiOS. Primarily used for navigation points. @@ -17,29 +15,6 @@ public enum WPActivityType: String { case notifications = "org.wordpress.notifications" } -extension WPActivityType { - var suggestedInvocationPhrase: String { - switch self { - case .siteList: - return NSLocalizedString("My Sites in WordPress", comment: "Siri Suggestion to open My Sites") - case .siteDetails: - return NSLocalizedString("WordPress Site Details", comment: "Siri Suggestion to open My Sites") - case .reader: - return NSLocalizedString("WordPress Reader", comment: "Siri Suggestion to open My Sites") - case .me: - return NSLocalizedString("WordPress Profile", comment: "Siri Suggestion to open Me tab") - case .appSettings: - return NSLocalizedString("WordPress App Settings", comment: "Siri Suggestion to open App Settings") - case .notificationSettings: - return NSLocalizedString("WordPress Notification Settings", comment: "Siri Suggestion to open Notification Settings") - case .support: - return NSLocalizedString("WordPress Help", comment: "Siri Suggestion to open Support") - case .notifications: - return NSLocalizedString("WordPress Notifications", comment: "Siri Suggestion to open Notifications") - } - } -} - /// NSUserActivity userInfo keys /// public enum WPActivityUserInfoKeys: String { @@ -49,30 +24,30 @@ public enum WPActivityUserInfoKeys: String { @objc public protocol SearchableActivityConvertable { /// Type name used to uniquly indentify this activity. /// - @objc var activityType: String {get} + @objc var activityType: String { get } /// Activity title to be displayed in spotlight search. /// - @objc var activityTitle: String {get} + @objc var activityTitle: String { get } // MARK: Optional Vars /// A set of localized keywords that can help users find the activity in search results. /// - @objc optional var activityKeywords: Set? {get} + @objc optional var activityKeywords: Set? { get } /// The date after which the activity is no longer eligible for indexing. If not set, /// the expiration date will default to one week from the current date. /// - @objc optional var activityExpirationDate: Date? {get} + @objc optional var activityExpirationDate: Date? { get } /// A dictionary containing state information related to this indexed activity. /// - @objc optional var activityUserInfo: [String: String]? {get} + @objc optional var activityUserInfo: [String: String]? { get } /// Activity description /// - @objc optional var activityDescription: String? {get} + @objc optional var activityDescription: String? { get } } public extension SearchableActivityConvertable where Self: UIViewController { @@ -105,11 +80,6 @@ public extension SearchableActivityConvertable where Self: UIViewController { activity.isEligibleForSearch = true activity.isEligibleForHandoff = false - activity.isEligibleForPrediction = true - - if let wpActivityType = WPActivityType(rawValue: activityType) { - activity.suggestedInvocationPhrase = wpActivityType.suggestedInvocationPhrase - } // Set the UIViewController's userActivity property, which is defined in UIResponder. Doing this allows // UIKit to automagically manage this user activity (e.g. making it current when needed) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 123cf2afc20d..f262e032b1a1 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,7 @@ * [*] Add App Shortcuts for creating a post and opening Notifications, Stats, and the Reader from Siri, Spotlight, and the Shortcuts app [#25754] * [*] Posts and Reader posts can now be found and opened from Siri and the Shortcuts app [#25755] * [*] Publish or schedule a post from Siri and the Shortcuts app, with a confirmation before anything goes live [#25756] +* [*] [internal] Stop donating screen activities as Siri predictions now that App Shortcuts cover them [#25757] 27.0 diff --git a/WordPress/Classes/System/WordPressAppDelegate.swift b/WordPress/Classes/System/WordPressAppDelegate.swift index 3d39fde86e11..f29a2535ce24 100644 --- a/WordPress/Classes/System/WordPressAppDelegate.swift +++ b/WordPress/Classes/System/WordPressAppDelegate.swift @@ -109,6 +109,7 @@ public class WordPressAppDelegate: UIResponder, UIApplicationDelegate { MemoryCache.shared.register() MediaImageService.migrateCacheIfNeeded() + purgeLegacySiriDonationsIfNeeded() PostCoordinator.shared.delegate = self // Start CrashLogging as soon as possible (in case a crash happens during startup) @@ -414,6 +415,19 @@ public class WordPressAppDelegate: UIResponder, UIApplicationDelegate { AccountService(coreDataStack: ContextManager.shared).mergeDuplicatesIfNecessary() } + /// Deletes the user activities donated as Siri predictions by earlier app versions, + /// because the app no longer donates predictions and the system keeps the old + /// suggestions until they are explicitly deleted. + // TODO: Remove this cleanup after a few releases. + private func purgeLegacySiriDonationsIfNeeded() { + let didPurgeKey = "did-purge-legacy-siri-donations" + guard !UserDefaults.standard.bool(forKey: didPurgeKey) else { + return + } + UserDefaults.standard.set(true, forKey: didPurgeKey) + NSUserActivity.deleteAllSavedUserActivities {} + } + private func setupPingHub() { pingHubManager = PingHubManager() }