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的更多相关文章

  1. 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 ...

  2. 在iPhone上同时关闭语音控制和siri的方法

    分享 步骤及要点:1.在设置里打开siri.语音控制就自动关闭了.2.在siri里的"仅语言拨号"语言项里选择"土耳其文"或者"阿拉伯文". ...

  3. 使用 Swift 在 iOS 10 中集成 Siri —— SiriKit 教程

    下载 Xcode 8,配置 iOS 10 和 Swift 3 (可选)通过命令行编译 除 非你想使用命令行编译,使用 Swift 3.0 的工具链并不需要对项目做任何改变.如果你想的话,打开 Xcod ...

  4. android shortcut &livefoulder

    android shortcut(实现步骤) 1.建立activity 2.minifest 里面注册并加上intent-filter,name为:android.intent.action.CREA ...

  5. 关于favicon.ico,shortcut icon,icon

    引入一篇文章.关于favicon.ico二三事. http://www.cnblogs.com/LoveJenny/archive/2012/05/22/2512683.html 一直对favicon ...

  6. Linux Shell shortcut

    Ctrl+a跳到第一个字符前Ctrl+x同上但再按一次会从新回到原位置 Details see below: Linux shell shortcut

  7. [转] 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 ...

  8. Xcode Custom Shortcut

    edit file "/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources" add < ...

  9. Android添加快捷方式(Shortcut)到手机桌面

    Android添加快捷方式(Short)到手机桌面 权限 要在手机桌面上添加快捷方式,首先需要在manifest中添加权限. <!-- 添加快捷方式 --> <uses-permis ...

  10. Django views 中的 shortcut function

    shortcut function都在django.shortcuts这个包中,主要包含有:render(), render_to_response(), redirect(), get_object ...

随机推荐

  1. 微服务组件--注册中心Spring Cloud Eureka分析

    Eureka核心功能点 [1]服务注册(register):Eureka Client会通过发送REST请求的方式向Eureka Server注册自己的服务,提供自身的元数据,比如ip地址.端口.运行 ...

  2. Dubbo-聊聊注册中心的设计

    前言 Dubbo源码阅读分享系列文章,欢迎大家关注点赞 SPI实现部分 Dubbo-SPI机制 Dubbo-Adaptive实现原理 Dubbo-Activate实现原理 Dubbo SPI-Wrap ...

  3. 9-模型层及ORM介绍

    一.模型层 模型层负责和数据库之间进行通信     二.Django配置mysql数据库 1.Django默认的数据库是sqllite3,将其更改为mysql数据库需要进行对应配置 1.安装mysql ...

  4. XAF新手入门 - 模块(Module)

    模块概述 谈到模块大家应该都不会感到陌生,不管是前端还是后端都有模块的概念,XAF中的模块概念与大多数框架中的模块概念是相通的.XAF模块首先是一个.NET类库,同时它还包含一个继承自ModuleBa ...

  5. Unity——射线检测(鼠标点击开关门效果)

    Unity射线检测--实现简单的开关门效果 简要:通过鼠标点击来发射一条射线,来获得射线所碰到的物体名称,再通过改变门的Rotation值来实现开关门的效果. 一.代码实现 1.1 简易的场景搭建 注 ...

  6. js 获取开始时间和结束时间相隔小时及分钟(时间戳操作)

    js 获取开始时间和结束时间相隔小时及分钟(时间戳操作) 场景描述:获取开始时间和结束时间相隔小时及分钟 实例: TimeOnConfirm(curDate) { if(this.pickernum ...

  7. element-ui el-table 多选和行内选中

    <template> <div style="width: 100%;height: 100%;padding-right: 10px"> <el-t ...

  8. mybatis-自定义映射resultMap

    自定义映射resultMap resultMap处理字段和属性的映射关系 resultMap:设置自定义映射 属性: id:表示自定义映射的唯一标识,不能重复 type:查询的数据要映射的实体类的类型 ...

  9. DNS 解析 prefeath

    本文将详细介绍DNS预解析prefetch的主要内容 概述 DNS(Domain Name System, 域名系统),是域名和IP地址相互映射的一个分布式数据库.DNS 查询就是将域名转换成 IP ...

  10. 【笔记】区间DP

    记录一些基础的区间 \(\text{DP}\) 题. 0x00 AT_dp_n N - Slimes 最板的区间 \(\text{DP}\) . 记 \(f[i][j]\) 表示合并 \(i\sim ...