Siri 快捷方式始终启动应用程序
Siri Shorcuts launches Application always
我在 phone 中添加了 Siri 快捷方式,每当我在 Siri 中调用快捷方式时,它都会打开 iOS 应用程序。
它没有执行我写的意图。
以下是我的IntentHandler.swift
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return self
}
}
我通过返回意图处理程序的实例解决了它。
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return ViewPointsIntentHandler()
}
}
并在 AppDelegate
文件中添加了以下方法,其中 ViewPointsIntent
是 Siri 快捷方式的目的。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let intent = userActivity.interaction?.intent as? ViewPointsIntent {
handle(intent)
return true
}
return false
}
private func handle(_ intent: ViewPointsIntent) {
let handler = ViewPointsIntentHandler()
handler.handle(intent: intent) { (response) in
print("success")
}
}
我在 phone 中添加了 Siri 快捷方式,每当我在 Siri 中调用快捷方式时,它都会打开 iOS 应用程序。
它没有执行我写的意图。
以下是我的IntentHandler.swift
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return self
}
}
我通过返回意图处理程序的实例解决了它。
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return ViewPointsIntentHandler()
}
}
并在 AppDelegate
文件中添加了以下方法,其中 ViewPointsIntent
是 Siri 快捷方式的目的。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let intent = userActivity.interaction?.intent as? ViewPointsIntent {
handle(intent)
return true
}
return false
}
private func handle(_ intent: ViewPointsIntent) {
let handler = ViewPointsIntentHandler()
handler.handle(intent: intent) { (response) in
print("success")
}
}