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 ...
随机推荐
- 创建第一个springboot项目、用springboot实现页面跳转、@Controller和@RestController的区别
文章目录 一.第一个spring boot项目 二.spring boot跳转到指定页面 三.怎样将后台的信息传递到前台 四. @Controller和@RestController的区别? 一.第一 ...
- 微服务组件--限流框架Spring Cloud Hystrix分析
Hystrix的介绍 [1]Hystrix是springCloud的组件之一,Hystrix 可以让我们在分布式系统中对服务间的调用进行控制加入一些调用延迟或者依赖故障的容错机制. [2]Hystri ...
- Android 13 新特性及适配指南
Android 13(API 33)于 2022年8月15日 正式发布(发布时间较往年早了一些),正式版Release源代码也于当日被推送到AOSP Android开源项目. 截止到笔者撰写这篇文章时 ...
- 【JavaSE】JDK 环境配置
下载 JDK 网站网址:oracle 安装 JDK 双击运行安装包 配置环境变量
- Java使用lamda表达式简化代码
代码,自然写的越简洁越好啦,写的人舒服,看的人也舒服,一切为了高效. 要把有限的时间花到其它有意思的事情上去. 目的 学习简化代码的思路,使用jdk8新特性lamada表达式. 使用 某接口,只有一个 ...
- JavaScript 实现地图搜索功能
需求:输入框输入地址点击查询,查询结果在地图定位到查询位置,显示查询位置的经纬度 <html xmlns="http://www.w3.org/1999/xhtml"> ...
- 网络编程:软件开发架构、架构总结、网络编程前戏、OSI七层协议简介、OSI七层协议之物理连接层、数据链路层、网络相关专业名词、OSI七层协议之网络层
目录 软件开发架构 架构总结 网络编程前戏 OSI七层协议简介 OSI七层协议之物理连接层 OSI七层协议之数据链路层 网络相关专业名词 OSI七层协议之网络层 OSI七层协议之传输层 软件开发架构 ...
- bugku web基础$_POST
这道题也是让what=flag就行了 直接试试通过max hackbar来进行post传入 得到flag
- 聊一聊如何截获 C# 程序产生的日志
一:背景 1.讲故事 前段时间分析了一个dump,一顿操作之后,我希望用外力来阻止程序内部对某一个com组件的调用,对,就是想借助外力实现,如果用 windbg 的话,可以说非常轻松,但现实情况比较复 ...
- day17 MySQL的安装 & 数据库基本语法——增删改查
day17 MySQL 登录数据库 mysql -h localhost -P 3307 -u root -p 查看所有数据库 show databases; 退出数据库 exit; //现有表格 u ...