I am attempting to trigger an action within a dynamic island by pressing a button, but the button is not functioning and no action is being executed.
dynamicIsland: { context in
DynamicIsland {
// Expanded UI goes here. Compose the expanded UI through
// various regions, like leading/trailing/center/bottom
DynamicIslandExpandedRegion(.leading) {
Text("Leading")
}
DynamicIslandExpandedRegion(.trailing) {
Text("Trailing")
}
DynamicIslandExpandedRegion(.bottom) {
Text("Bottom")
** Button {
//Print here
print("Pressed")
} label: {
Text("Press Me")**
}.padding()
}
} compactLeading: {
I have tried testing in a new project, but I am still encountering the same problem with the button not firing any action.
You can't use buttons in live activities the same way you do in an app. You need to use the App Intents Framework instead. Then you would add a button with the
init(_:intent:)
initializer.From the documentation: