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:
<;
<;
<;
本文标签:
版权声明:本文标题:swiftui - Inside my iOS homescreen widget, how do I trigger ios input dialog (similar to Shortcut's Ask for input text a 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744883358a2630341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论