I'm using LiveActivityIntent in the following way to add interactive buttons to my Live Activity:
struct Test: LiveActivityIntent {
static var title: LocalizedStringResource = "Test"
public init() { }
func perform() async throws -> some IntentResult {
return .result()
}
}
This works as expected. However, the LiveActivityIntent also shows up in the Shortcuts app. That does not make sense because the buttons should not be user-configurable. How can I hide the button intents from the Shortcuts app?
Looking at the AppIntent
protocol (which LiveActivityIntent
also inherits), there is a static property isDiscoverable
:
/// A boolean value that determines whether system features such as Shortcuts
/// and Spotlight can discover this app intent.
///
/// App Intents must be discoverable to support App Shortcuts. If your
/// app intent isn't discoverable, people can use it only when it's directly
/// connected by a button in a SwiftUI app or a widget.
///
/// This property is `true` by default.
///
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
static var isDiscoverable: Bool { get }
In your case, you can set isDiscoverable
to false
struct Test: LiveActivityIntent {
static var title: LocalizedStringResource = "Test"
static var isDiscoverable: Bool = false
public init() { }
func perform() async throws -> some IntentResult {
return .result()
}
}