gpt4 book ai didi

ios - SiriKit 错误 : Donating intent is not supported by this application

转载 作者:可可西里 更新时间:2023-11-01 04:49:37 25 4
gpt4 key购买 nike

我在 Xcode 10(iOS 12 Beta)中提供自定义意图时遇到问题。

我已经创建了一个在我的主要应用程序目标和我的“OrderIntent”目标之间共享的自定义框架。

我创建了一个 .intentdefinition 文件,目标成员设置为我的自定义框架(下面的屏幕截图)。

enter image description here

我在主应用程序中嵌入了“Intents Extension”和“Intents UI Extension”。

我还在添加意图扩展时创建的两个 info.plist 文件中的 NSExtension->NSExtensionAttributes->IntentsSupported 添加了“OrderIntent”(下面的屏幕截图)。

enter image description here

我正在尝试像这样捐赠意图:

INPreferences.requestSiriAuthorization { (status) in

if status != INSiriAuthorizationStatus.authorized {return}

let orderIntent = OrderIntent()
orderIntent.product = "Test product"
orderIntent.quantity = 2

let interaction = INInteraction(intent: customIntent, response: nil)

interaction.donate { (error) in
if error != nil {2
if let error = error as NSError? {
print(error)
}
} else {
print("success")
}
}
}

上面的代码在用户点击应用中的按钮时运行。

我还像这样设置了意图处理程序:

class IntentHandler: INExtension {

override func handler(for intent: INIntent) -> Any {

switch intent {
case is OrderIntent:
return OrderIntentHandler()

default:
fatalError()
}

return self
}

OrderIntentHandler 是这样的:

public class OrderIntentHandler: NSObject, OrderIntentHandling {

public func handle(intent: OrderIntent, completion: @escaping (OrderIntentResponse) -> Void) {

let orderIntentResponse = OrderIntentResponse(code: OrderIntentResponseCode.success, userActivity: nil)

completion(orderIntentResponse)
}

public func confirm(intent: OrderIntent, completion: @escaping (OrderIntentResponse) -> Void) {

let response = OrderIntentResponse(code: OrderIntentResponseCode.ready, userActivity: nil)

completion(response)
}
}

在设备上测试时,出现以下错误:

Error Domain=IntentsErrorDomain Code=1901 "Donating intent 'OrderIntent' is not supported by this application. Please make sure that you have an extension that supports this intent." UserInfo={NSLocalizedDescription=Donating intent 'OrderIntent' is not supported by this application. Please make sure that you have an extension that supports this intent.}

我不明白为什么应用程序不支持“OrderIntent”。

我已经在功能选项卡中启用了 Siri 并请求了用户的许可等。

是否需要采取任何其他步骤才能让我捐赠 intent?

最佳答案

我相信你的问题的答案在你的描述中是正确的(强调我的):

I've created a .intentdefinition file with the target membership set to my custom framework

我假设执行调用 interaction.donate 的代码在您的应用程序中,而不是在共享框架中。如果是这种情况(根据 your answer 判断您如何解决该问题),您还需要将主应用程序添加为 .intentdefinition 文件中的目标。您将希望没有生成的类,因为它们已经在您的应用程序链接到的共享框架中。您可能遇到了问题,因为看起来您在单独的 Xcode 项目中创建了共享框架,因此其他目标不可见。

关于ios - SiriKit 错误 : Donating intent is not supported by this application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50817087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com