swift - 使用完成块的自定义意图处理程序
问题描述
我正在使用自定义 Siri 意图来 ping 服务器。我用来 ping 的函数在完成块中返回,如下所示:
PingKit.trace(host: server.pingURL, maxTraceTTL: 15) { latency, _ in
// Do something cool here
}
但是,当我尝试在我的自定义意图处理程序中使用它时,我从来没有得到我想要的反馈。是否有特定方法可以在意图处理程序中使用完成块函数,以便我可以成功执行以下操作?
func handle(intent: RunTestIntent, completion: @escaping (RunTestIntentResponse) -> Void) {
let server = Server(name: "Google",
pingURL: "www.google.com",
isPingTestable: true,
ndtURL: "10.10.43.146:4443",
isNDTTestable: true,
geo: Geo.NorthAmerica)
PingKit.trace(host: server.pingURL, maxTraceTTL: 15) { latency, _ in
completion(RunTestIntentResponse.success(result: "Test Complete"))
}
}
解决方案
推荐阅读
- sql - 用于发送电子邮件 dbmail 的用户授权
- c# - FirstOrDefault() 导致 Collection 被修改;枚举操作可能无法执行。例外
- snowflake-sql - 在特定事件之后的行 FOR A KEY
- php - 使用googlespreadsheet api v4批量更新单个单元格?
- r - 如何使用 R 中的 Hayes Process 更改调解调解的调解人值
- algorithm - 对于两个非负函数 f 和 g,如果 f = O(g) 和 g = O(f) 并且 ∀n,f(n) > g(n) 则证明或反证 f - g = O(1)
- reactjs - 如果提供了某些值,有没有办法使所需的打字稿值可选?
- firebase - 我遇到“错误:没有为类型“对象”定义运算符“[]”。我该如何解决这个问题?
- azure - Azure 二头肌资源模块的依赖性问题
- react-native - Trouble migrating React Navigation v4 Deep Link configuration to React Navigation v5