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 ...
随机推荐
- 后端框架学习-----mybatis(4)
文章目录 4.解决属性名和字段名不一致的问题 4.解决属性名和字段名不一致的问题 1.问题.数据库字段名和属性名不一致,导致查出的数据部分为空 2.resultMap(用于解决数据库表中的字段和属性) ...
- goroutine&waitgroup下载文件
0.1.索引 https://blog.waterflow.link/articles/1663078266267 当我们下载一个大文件的时候,会因为下载时间太久而超时或者出错.那么我么我们可以利用g ...
- Redis 常见问题-缓存穿透
问题描述: * 针对 DB 中不存在的数据源,每次请求缓存和数据库都不存在 造成后果: * 应用服务器压力变大 * Redis 命中率大幅度降低 * `数据库压力巨增甚至 down 掉`* 该现象对于 ...
- 【神经网络】丢弃法(dropout)
丢弃法是一种降低过拟合的方法,具体过程是在神经网络传播的过程中,随机"沉默"一些节点.这个行为让模型过度贴合训练集的难度更高. 添加丢弃层后,训练速度明显上升,在同样的轮数下测试集 ...
- vue中动态引入图片为什么要是require, 你不知道的那些事
相信用过vue的小伙伴,肯定被面试官问过这样一个问题:在vue中动态的引入图片为什么要使用require 有些小伙伴,可能会轻蔑一笑:呵,就这,因为动态添加src被当做静态资源处理了,没有进行编译,所 ...
- certutil做哈希校验并下载网络文件
微软Win系统自带,不需要安装的工具,但它是CMD命令行工具,关于命令行工具的说明和使用请参考我以前的文章 Windows系统的命令行(CLI)介绍及入门使用说明 . 这个微软自带的命令行工具叫做 c ...
- iOS开发应用上传AppStore的步骤
原文:http://blog.csdn.net/ayangcool/article/details/46647693 前言:作为一名IOS开发者,把开发出来的App上传到App Store是必须的 ...
- LVS之NAT、DR、TUNNEL实验
1.LVS-NAT规则+WRR算法 服务器 IP地址 作用 系统版本 RS1 10.0.0.8/24GW:10.0.0.101 网站服务器 Rocky8.6 RS2 10.0.0.18/24GW:10 ...
- while、for循环结合else
"""1.while else,当while循环正常结束时,才走else里的代码块,也就是没有被break打断的情况下2.此处只是不被break打断,也就是遇到break ...
- 1.nginx学习
我们平时访问的网络网站就是WEB网络服务,允许用户通过浏览器访问互联网中的各种资源服务 WEB服务器会通过HTTP或者HTTPS的方式将请求内容传递给客户端 目前常见的WEB服务有IIS, Nginx ...