Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the physical Action button of the Apple Watch Ultra?

Is there a way to read the Action button of the Apple Watch Ultra in SwiftUI?

enter image description here

You can read the Digital Crown like in the example below, but I've found nothing similar for the Action button?

struct DigitalCrown: View {
    @State private var crownValue = 0.0

    var body: some View {
        Text("Received Value:\(crownValue, specifier: "%.1f")")
            .focusable()
            .digitalCrownRotation($crownValue)
    }
}
like image 893
Daniel Avatar asked Oct 26 '25 21:10

Daniel


2 Answers

I haven't found how to designate an action but there is a UI test.

XCUIDevice.current.press(.action)

https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes

From the wording I am guessing it might be a "Shortcut"

like image 113
lorem ipsum Avatar answered Oct 29 '25 14:10

lorem ipsum


The Apple Watch Ultra’s Action Button is powered by new App Intents APIs. You will be able to build your own apps to integrate with it, like a hockey app that uses the button to record goals. And for users, the button can kick off any Shortcut you want.

To use this, make an Intent that conforms to the StarWorkoutIntent protocol: https://developer.apple.com/documentation/appintents/startworkoutintent

These APIs are meant for Workout apps, so to put this new button in a mode where it’s controlling your app, you’ll need to at least start with a StartWorkoutIntent.

Once you’re done with that, you can create an AppIntent result with an actionButtonIntent to set the next thing the button will do, to any other intent. Or, if you’re changing the button’s behavior based on something that happened in your app’s UI, you can use donations to do so.

https://twitter.com/mgorbach/status/1567570300820144131

like image 29
malhal Avatar answered Oct 29 '25 13:10

malhal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!