admin管理员组

文章数量:1405135

enter image description here

TLDR I want user to be able to quickly update text status within the home screen widget, without the need to open my app, but not sure how to code it or if it even possilble.

Is it possible to in iOS 17/18 to trigger a text field input dialog when I tapped on my button inside my app's home screen interactive widget? I've been looking for solutions for almost a week and seems like nothing works. I'm certain it could be done because when I'm using the Shortcuts app home widget (not just add to home icon bookmark), it can directly trigger the text input prompt overhead.

solution that I've tried is that I create an new appintents for this button to trigger, where inside the intent I tried:

```lang-swift

struct UpdateStatusIntent: AppIntent {
     static var title: LocalizedStringResource = "Update Status"
     static var description = IntentDescription("Update your status with custom text")
    
     @Parameter(title: "Status Text", description: "The text to update your status with")
     var statusText: String
    
     init() {}
    
     init(statusText: String) {
         self.statusText = statusText
     }
    

     @MainActor
     func perform() async throws -> some ReturnsValue<String> {
         return .result(value: statusText, dialog: IntentDialog(stringLiteral: "Status updated to: \(statusText)"))
     }
    
 }

- above code works when I create App Shortcut using that intent, it triggers the input text dialog, but not when I tap on my widget button.

- I also tried to use URL and x-callback-URL, but still nothing happened after tapping the button. If I add a 'print' statement inside the perform(), the print is showing, but nothing happens still.

above image explanation: as you can see I want to open that input text field when i tap on the blue bell icon button, but I still can't. The input dialog is just for example of what I want, and is triggered using random Shortcut app Ask for input button.

Really appreciate any enlightment on this, thank you.

some of my references documentation:

<;

<;

<;

本文标签: