Xcode 10 (iOS 12 Beta) でカスタム インテントを寄付する際に問題が発生しています。
メインのアプリ ターゲットと「OrderIntent」ターゲットの間で共有されるカスタム フレームワークを作成しました。
ターゲット メンバーシップがカスタム フレームワークに設定された .intentdefinition ファイルを作成しました (下のスクリーンショット)。
メイン アプリケーション内に「Intents Extension」と「Intents UI Extension」を組み込みました。
また、インテント拡張機能を追加したときに作成された両方の info.plist ファイルで、「OrderIntent」を NSExtension->NSExtensionAttributes->IntentsSupported に追加しました (下のスクリーンショット)。
私はこのような意図を寄付しようとしています:
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)
}
}
これをデバイスでテストすると、次のエラーが発生します。
エラー Domain=IntentsErrorDomain Code=1901 「インテント 'OrderIntent' の寄付は、このアプリケーションではサポートされていません。このインテントをサポートする拡張機能があることを確認してください。」UserInfo={NSLocalizedDescription=寄付インテント「OrderIntent」は、このアプリケーションではサポートされていません。このインテントをサポートする拡張機能があることを確認してください。}
「OrderIntent」がアプリケーションでサポートされていない理由がわかりません。
機能タブで既に Siri を有効にしており、ユーザーなどに許可を要求しています。
インテントを寄贈できるようにするために他に必要な手順はありますか?