【发布时间】:2020-12-25 13:23:40
【问题描述】:
我的应用程序应该向快捷方式应用程序捐赠一个快捷方式,以检索随机图像。 但是我无法返回图像,并且确实了解应该如何完成。
我的意图文件如下。由于“图像”不是可能的返回类型,我改为返回一个文件。
我的代码:
class TestIntentHandler: NSObject, TestIntentIntentHandling {
func handle(intent: TestIntentIntent, completion: @escaping (TestIntentIntentResponse) -> Void) {
let response = TestIntentIntentResponse(code: .success, userActivity: nil)
let data = UIImage(named: "test")!.pngData()!
response.image = INFile(data: data, filename: "tester", typeIdentifier: "png")
completion(response)
}
func confirm(intent: TestIntentIntent, completion: @escaping (TestIntentIntentResponse) -> Void) {
completion(TestIntentIntentResponse(code: .ready, userActivity: nil))
}
}
但测试快捷方式不显示图像。
【问题讨论】:
标签: ios swift xcode sirikit sirishortcuts