Siri Shortcut
AppDelegate.m
//#pragma mark - INUIAddVoiceShortcutButtonDelegate
//新添加
- (void)presentAddVoiceShortcutViewController:(INUIAddVoiceShortcutViewController*)addVoiceShortcutViewControllerforAddVoiceShortcutButton:(INUIAddVoiceShortcutButton*)addVoiceShortcutButton API_AVAILABLE(ios(12.0)){
//新添加接口的代理
addVoiceShortcutViewController.delegate=self;
[selfpresentViewController:addVoiceShortcutViewControlleranimated:YEScompletion:nil];
}
#pragma mark -INUIEditVoiceShortcutViewControllerDelegate
//添加过,去编辑
- (void)presentEditVoiceShortcutViewController:(INUIEditVoiceShortcutViewController*)editVoiceShortcutViewControllerforAddVoiceShortcutButton:(INUIAddVoiceShortcutButton*)addVoiceShortcutButton API_AVAILABLE(ios(12.0)){
//编辑接口的代理
editVoiceShortcutViewController.delegate=self;
[selfpresentViewController:editVoiceShortcutViewControlleranimated:YEScompletion:nil];
}
#pragma mark - INUIAddVoiceShortcutViewControllerDelegate
- (void)addVoiceShortcutViewController:(INUIAddVoiceShortcutViewController*)controllerdidFinishWithVoiceShortcut:(nullableINVoiceShortcut*)voiceShortcuterror:(nullableNSError*)error API_AVAILABLE(ios(12.0)){
if(!error) {
NSLog(@"%@, %@", voiceShortcut.invocationPhrase, voiceShortcut.identifier);
[controllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"添加成功");
}];
}else{
NSLog(@"%@", error.localizedDescription);
}
}
- (void)addVoiceShortcutViewControllerDidCancel:(INUIAddVoiceShortcutViewController*)controller API_AVAILABLE(ios(12.0)){
[controllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"取消添加");
}];
}
- (void)editVoiceShortcutViewController:(INUIEditVoiceShortcutViewController*)controllerdidUpdateVoiceShortcut:(nullableINVoiceShortcut*)voiceShortcuterror:(nullableNSError*)error API_AVAILABLE(ios(12.0)){
if(!error) {
NSLog(@"%@, %@", voiceShortcut.invocationPhrase, voiceShortcut.identifier);
[controllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"修改成功");
}];
}else{
NSLog(@"%@", error.localizedDescription);
}
}
- (void)editVoiceShortcutViewController:(INUIEditVoiceShortcutViewController *)controller didDeleteVoiceShortcutWithIdentifier:(NSUUID*)deletedVoiceShortcutIdentifier API_AVAILABLE(ios(12.0)){
[controllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"删除命令");
}];
}
- (void)editVoiceShortcutViewControllerDidCancel:(INUIEditVoiceShortcutViewController*)controller API_AVAILABLE(ios(12.0)){
[controllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"取消添加");
}];
}
//判断 可以自定义添加到Siri按钮
- (void)isVoiceShortcutExist {
//回调再子线程,如操作UI需要回到主线程
if(@available(iOS12.0, *)) {
[[INVoiceShortcutCentersharedCenter]getAllVoiceShortcutsWithCompletion:^(NSArray<invoiceshortcut*> *_NullablevoiceShortcuts,NSError*_Nullableerror) {
if(!error) {
for(INVoiceShortcut*shortcutinvoiceShortcuts) {
//存在
if ([shortcut.shortcut.userActivity.activityType isEqualToString:@"Imy.SiriShortcut"]) {
dispatch_async(dispatch_get_main_queue(), ^{
//添加一个按钮,可以点击跳转INUIEditVoiceShortcutViewController,INUIEditVoiceShortcutViewController需要自己生成
INUIEditVoiceShortcutViewController *editVC = [[INUIEditVoiceShortcutViewController alloc] initWithVoiceShortcut:shortcut];
editVC.delegate=self;
[selfpresentViewController:editVCanimated:YEScompletion:^{
}];
});
}else{
//不存在
dispatch_async(dispatch_get_main_queue(), ^{
//添加一个按钮,可以点击跳转INUIAddVoiceShortcutViewController,INUIAddVoiceShortcutViewController需要自己生成
INShortcut* shortCut = [[INShortcutalloc]initWithUserActivity:[selfcreateRelevantUserActivity]];
INUIAddVoiceShortcutViewController *addVC = [[INUIAddVoiceShortcutViewController alloc] initWithShortcut:shortCut];
addVC.delegate=self;
[selfpresentViewController:addVCanimated:YEScompletion:^{
}];
});
}
}
}
}];
}
}
Siri Shortcut的更多相关文章
- Eclipse CDT: Shortcut to switch between .h and .cpp
ctrl+ tab is the default shortcut.You can change it in Window → Preferences → General → Keys: Toggl ...
- 在iPhone上同时关闭语音控制和siri的方法
分享 步骤及要点:1.在设置里打开siri.语音控制就自动关闭了.2.在siri里的"仅语言拨号"语言项里选择"土耳其文"或者"阿拉伯文". ...
- 使用 Swift 在 iOS 10 中集成 Siri —— SiriKit 教程
下载 Xcode 8,配置 iOS 10 和 Swift 3 (可选)通过命令行编译 除 非你想使用命令行编译,使用 Swift 3.0 的工具链并不需要对项目做任何改变.如果你想的话,打开 Xcod ...
- android shortcut &livefoulder
android shortcut(实现步骤) 1.建立activity 2.minifest 里面注册并加上intent-filter,name为:android.intent.action.CREA ...
- 关于favicon.ico,shortcut icon,icon
引入一篇文章.关于favicon.ico二三事. http://www.cnblogs.com/LoveJenny/archive/2012/05/22/2512683.html 一直对favicon ...
- Linux Shell shortcut
Ctrl+a跳到第一个字符前Ctrl+x同上但再按一次会从新回到原位置 Details see below: Linux shell shortcut
- [转] Fix: Screen Clipping Shortcut In OneNote Not Working After Upgrading To Windows 8.1
RECOMMENDED: Click here to fix Windows errors and optimize system performance No doubt, OneNote is y ...
- Xcode Custom Shortcut
edit file "/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources" add < ...
- Android添加快捷方式(Shortcut)到手机桌面
Android添加快捷方式(Short)到手机桌面 权限 要在手机桌面上添加快捷方式,首先需要在manifest中添加权限. <!-- 添加快捷方式 --> <uses-permis ...
- Django views 中的 shortcut function
shortcut function都在django.shortcuts这个包中,主要包含有:render(), render_to_response(), redirect(), get_object ...
随机推荐
- 1.轮询、长轮询、websocket简介
一.轮询 前端每隔固定时间向后台发送一次请求,询问服务器是否有新数据 缺点: 延迟,需要固定的轮询时间,不一定是实时数据 大量耗费服务器内存和宽带资源,因为不停的请求服务器,很多时候 并没有新的数 ...
- 4.可视化API
模式视图(可浏览api界面) #导包 依赖coreapi from rest_framework.schemas import get_schema_view # 将get_schema_view视图 ...
- 驱动开发:内核监控FileObject文件回调
本篇文章与上一篇文章<驱动开发:内核注册并监控对象回调>所使用的方式是一样的都是使用ObRegisterCallbacks注册回调事件,只不过上一篇博文中LyShark将回调结构体OB_O ...
- ML-梯度下降法的详细推导与代码实现
计算 对于线性回归,梯度下降法的目标就是找到一个足够好的向量\(\theta\),使代价函数\(J(\theta) = \sum_{i=1}^{m}(\hat{y}-y_{i})^{2}\)取得最小值 ...
- shardingsphere-jdbc 水平分表学习记录
放在自己博客里搬过来一份~ 前司使用的是自己魔改的TDDL,在家时间比较多就尝试学一些业内比较常用的中间件. 这里记录一下学习中遇到的一些问题. 环境 设置的比较简单(太懒了就测试了几个表), 两个分 ...
- 基于 .NET 7 的 QUIC 实现 Echo 服务
前言 随着今年6月份的 HTTP/3 协议的正式发布,它背后的网络传输协议 QUIC,凭借其高效的传输效率和多路并发的能力,也大概率会取代我们熟悉的使用了几十年的 TCP,成为互联网的下一代标准传输协 ...
- JS数据结构与算法-概述
JS数据结构与算法概述 数据结构: 计算机存储, 组织数据的方式, 就像锅碗瓢盆 算法: 一系列解决问题的清晰指令, 就像食谱 两者关系: 程序 = 数据结构 + 算法 邂逅数据结构与算法 什么是数据 ...
- CSP-S2022 游寄
前言:最后确实寄了,因为疫情,都没考成. \(8.26\) 占坑. \(8.23\) 参加浴谷月赛初赛模拟,报的 \(S\) 组,只有 \(71\) 分. \(8.25\) \(AK\) 了同学出的比 ...
- SQLi
点进去发现是个空白网页,查看源码发现一个login.php的文件,话不多说,直接选择复制然后访问 Url: http://5865f5830d034083b9bbc0dafc6b60a5d5d2309 ...
- 在 win11 下搭建并使用 ubuntu 子系统(同时测试 win10)——(附带深度学习环境搭建)
对于一个深度学习从事者来说,Windows训练模型有着诸多不便,还好现在Windows的Ubuntu子系统逐渐完善,近期由于工作需求,配置了Windows的工作站,为了方便起见,搭建了Ubuntu子系 ...