- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试将 Siri 快捷方式集成到我的应用程序中。我正在尝试的概念是通过密码确认获得我的卡的奖励积分。请在下面找到我为此所做的工作。
添加了名为 say Rewards 的新自定义意图。
定义标题。启用确认的字幕和参数(accType,pin)。 Pin 将单独发送给用户。
//
// RewardsIntentHandler.swift
// SiriIntentExt
//
import UIKit
import Intents
class RewardsIntentHandler: NSObject, RewardsIntentHandling {
func resolveAccType(for intent:RewardsIntent, with completion: @escaping ([INStringResolutionResult]) -> Void) {
guard let accType = intent.accType else {
completion([INStringResolutionResult.needsValue()])
return
}
completion([INStringResolutionResult.success(with: accType)])
}
func resolvePin(for intent:RewardsIntent, with completion: @escaping ([INIntegerResolutionResult]) -> Void) {
guard let verifyPin = intent.pin else {
completion([INIntegerResolutionResult.needsValue()])
return
}
completion([INIntegerResolutionResult.confirmationRequired(with: verifyPin as? Int)])
}
func confirm(intent: RewardsIntent, completion: @escaping (RewardsIntentResponse) -> Void) {
completion(RewardsIntentResponse.init(code: RewardsIntentResponseCode.ready, userActivity: nil))
}
func handle(intent: RewardsIntent, completion: @escaping (RewardsIntentResponse) -> Void) {
guard intent.accType != nil else {
completion(RewardsIntentResponse.init(code: RewardsIntentResponseCode.continueInApp, userActivity: nil))
return
}
guard intent.pin != nil else {
completion(RewardsIntentResponse.init(code: RewardsIntentResponseCode.continueInApp, userActivity: nil))
return
}
let response = RewardsIntentResponse.success(rewardPoints: NSNumber(value: 3453))
completion(response)
}
}
//
// IntentHandler.swift
// SiriIntentExt
//
import Intents
class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
if intent is RewardsIntent {
return RewardsIntentHandler()
}
return self
}
}
//
// ViewController.swift
// Shortcuts
//
import UIKit
import Intents
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
siriAuthorisarion()
donateRewardIntent()
}
func siriAuthorisarion() {
INPreferences.requestSiriAuthorization { (status) in
print("Siri Authorization Status - ", status)
}
}
func donateRewardIntent() {
let rewardsIntent = RewardsIntent()
rewardsIntent.suggestedInvocationPhrase = "Reward Points"
rewardsIntent.accType = "test account"
let interaction = INInteraction(intent: rewardsIntent, response: nil)
interaction.donate { error in
if let error = error {
print("Donating intent failed with error \(error)")
}
DispatchQueue.main.async {
let alert = UIAlertController.init(title: ((error != nil) ? "Error" : "Success"), message: ((error != nil) ? "Oops!!! Error occured on donating intent." : "Intent donated succussfully!!!"), preferredStyle: .alert)
alert.addAction(UIAlertAction.init(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
}
我正面临来自上述代码库的问题。 Siri 没有请求密码,也无法获得该帐户的确切奖励积分。
有以下问题。
提前致谢。
最佳答案
找到我对以上问题的分析。
默认情况下,会为特定领域(例如消息、支付、照片、锻炼等)提供意图。无需通过快捷方式为这些特定领域显式添加意图。除了这些域之外,如果我们要创建自定义意图,我们还需要使用快捷方式/设置应用程序捐赠和添加意图到 Siri。
从 iOS13 开始,Apple 为自定义 Intent 添加了 Siri 参数和 Siri 建议以请求缺少的参数。直到 iOS12,我们没有自定义意图的参数选项。
在 iOS12 中,我们无法为自定义 Intent 中的参数添加 resolve 方法。仅针对问题 1 中提到的 Intents 扩展中提供的特定域处理的 Resolve 方法。从 iOS13 开始,我们可以根据参数为自定义 Intent 提供 resolve 方法。
我们可以添加断点和调试意图处理程序方法。
谢谢。
关于ios - Siri 与自定义意图的集成面临问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57513364/
我已经为应用程序实现了 Siri 快捷方式。一切正常,除了一件事: 当执行 INPreferences.requestSiriAuthorization 请求使用 Siri 的授权时,用户可以允许或拒
我知道有 no API for Siri .看起来也没有迹象表明它会很快发生变化。 但我迫不及待地想利用它出色的自由语音识别功能,所以我在想也许仍在使用它但作为一个“黑匣子”? 例如,this app
这个问题在这里已经有了答案: Does Apple provide an API for SIRI? (4 个回答) 5年前关闭。 我可以像使用 iOS 应用程序一样使用 Siri 功能对 macOS
我需要集成 Siri 才能使用我的应用调用电话。 Siri 在设置的应用程序支持上识别我的应用程序。但是当我试图调用某个联系人说“在 MyApp 上调用 ContactName”时,它只显示按钮“打开
我已经通过 react-native-siri-shortcut npm 在 React Native 项目中成功实现了快捷方式。 我可以在快捷方式应用程序(iOS 中)中看到所有这些快捷方式。 当我
我在 iOS 应用程序上有一个可用的 Siri 支付扩展程序。但是当我问 Siri“你能做什么?”它没有列出我的应用程序。 Siri 确实列出了现金和 Venmo 支付应用程序(我同事手机上的 Ven
我想知道是否可以在移动设备上使用 JS 验证一些 Siri 驱动(或 Android 语音识别软件)的输入。 我有一个“input type=text”对象,但我只需要启用数字(数字)。我正在使用 k
AppleTV 似乎存在错误。我有一个包含所有游戏节点(和 Action )的 SKNode“worldNode”的 SpriteKit 场景。我能够检测到何时按下 Siri Remote 上的菜单按
我正在集成 Sirikit,Bill Payment,目的是: INPayBillIntentHandling(最近在 iOS 10.3+ 中发布,2017 年 3 月 27 日)。 Apple 文档
我想通过终端命令来使用 siri。是否可以?示例: $ siri "Sleep my mac" 最佳答案 您可以使用 siri 在“设置”>“辅助功能”>“语音”中设置萨曼莎的声音 打开终端并输入 $
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _recordingTap == nil 代码崩溃 1.
我的应用程序有一个自定义意图,它向用户建议一个快捷方式,如下所示: let intent = ReadIntent() if let shortcut = INShortcut(int
这个问题在这里已经有了答案: 已关闭10 年前。
有没有一种方法或工具可以检查 Apple 的 Siri 如何解释/读取语音字段的值?我已经能够在终端 (Mac OSX) 中通过 say something 帮助自己一点点,但我对任何其他替代方案感到
我知道这是一个长期的尝试,但是有什么方法可以将数据推送到 iOS 上的 Siri。 我的意思是,我有一个程序,其中包含一些数据,例如我的购物 list 或其他数据。现在我想问 Siri 我需要买什么,
有没有办法从网页(可能使用 Javascript)触发 Siri 来填充输入文本字段? 最佳答案 您可能无法直接触发 Siri,但您可以使用 x-webkit-speech将添加使用语音输入功能的 h
我正在尝试将 Siri 快捷方式集成到我的应用程序中。我正在尝试的概念是通过密码确认获得我的卡的奖励积分。请在下面找到我为此所做的工作。 在功能中启用 Siri 并添加 Siri Intent 定义文
我已启动并运行快捷方式,并且已将自定义响应添加到我的完成处理程序中。在这种情况下... completion ([TriggerSceneIntentResponse successIntentR
在 Apple TV 上的 Siri Remote 上收集触摸时,触摸的位置始终报告为同一位置? let tapRecognizer = UITapGestureRecognizer(target:
我是一名优秀的程序员,十分优秀!