如何将 Siri 快捷方式操作(SiriKit 意图)添加到应用程序?

发布于 2025-01-17 08:17:35 字数 213 浏览 1 评论 0原文

我正在构建我的第一个应用程序,我需要向其中添加 Siri 快捷方式操作(SiriKit Intents),老实说,我无法在网上找到任何与最新版本的 Xcode 保持同步的可靠资源,我找到了 ToolBox Pro for Shortcuts 的开发人员提供的一个,但在第二部分中我遇到了一些问题。 你们中有人知道有什么好的资源可以学习如何将快捷方式操作集成到 SwiftUI 应用程序中吗? (斯威夫特用户界面)

I'm working on building my first app, and I need to add Siri Shortcuts actions (SiriKit Intents) to it, I honestly am not able to find any reliable resources online which are up-to-date with the latest version of Xcode, I found one by the developer of ToolBox Pro for Shortcuts, but I'm facing a few issues following along in the part two.
Do any of you all know any good resources for learning how to integrate Shortcuts actions into SwiftUI apps? (SwiftUI)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮倦 2025-01-24 08:17:35

您可以在此处找到文档,以添加自定义 SiriKit Intent定义文件到您的项目。他们为您提供了定义意图参数的示例。

然后在 SwiftUI 中使用修饰符 onContinueUserActivity。更多文档请参见此处。这几乎就是将 Siri Shortcuts 添加到您的 SwiftUI 项目所需的全部内容,这正是我在 SwiftUI 应用程序中完成此操作的方式。

.onContinueUserActivity(_ activityType: String, perform action: @escaping (NSUserActivity) -> ())

Documentation can be found here to add a custom SiriKit Intent Definition File to your project. They give you examples of defining intent parameters.

Then use the modifier onContinueUserActivity in SwiftUI. More documentation available here. That's pretty much all you need to add Siri Shortcuts to your SwiftUI project, exactly how I accomplished this in my SwiftUI app.

.onContinueUserActivity(_ activityType: String, perform action: @escaping (NSUserActivity) -> ())
放肆 2025-01-24 08:17:35

要添加 Siri 快捷方式意图,请转到 文件 >新的>新文件> Sirikit意图定义文件

To add Siri shortcut intents go to File > New > New File > Sirikit Intent Defination File

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文