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. Vue中组件化编码使用(实战练习一)

    Vue中组件化编码的大致流程(初接触).组件之间的参数传递(最基础的形式).组件之间的配合完成一个需求 1.在Vue中进行组件化编码 1.1.组件化编码流程: (1).拆分静态组件:组件要按照功能点拆 ...

  2. 初始Vue、Vue模板语法、数据绑定(2022/7/3)

    文章目录 1.Vue简介 1.1.Vue的安装使用 1.2.实际的运用案例 1.3.vue开发工具的使用(这个需要在浏览器中安装) 2.初始Vue 2.1 .基础知识 2.1 .代码实例 2.2 .页 ...

  3. 5.github操作

      Github设置远程仓库 将我们github的https或者ssh远程仓库地址复制 git remote add https://xxxxxxxTest.git # 指定github仓库设置为远程 ...

  4. AR人体姿态识别,实现无边界的人机交互

    近年来,AR不断发展,作为一种增强现实技术,给用户带来了虚拟和现实世界的融合体验.但用户已经不满足于单纯地将某件虚拟物品放在现实场景中来感受AR技术,更想用身体姿势来触发某个指令,达到更具真实感的人机 ...

  5. ssh登录提示hosts is down

    其他无用的网卡配置信息mv走重启network如果还是不行重启一下服务器问题就能解决

  6. Linux文件属性与管理

    文件或目录属性主要包括: 索引节点,inode 文件类型 文件权限 硬链接个数 归属的用户和用户组 最新修改时间 查看命令 ls -lhi /opt 图解: Inode索引节点号,(人的身份证,家庭地 ...

  7. 7.Vue常用属性

    1. data:数据属性 在之前的学习中我们已经了解到了data,属性中存放的就是js变量 <script> new Vue({ el: '#app', // data data: { u ...

  8. uniapp/微信小程序 项目day03

    一.商品列表 1.1 获取数据 首先能够进入商品列表的途径 传的数据有 了解了这个之后就可以开始了,先创建分支 创建编译模式,并分配初试数据 这个时候就可以获取数据了 需要的数据 所以在发起请求之前需 ...

  9. 第2-2-4章 常见组件与中台化-常用组件服务介绍-分布式ID-附Snowflake雪花算法的代码实现

    目录 2.3 分布式ID 2.3.1 功能概述 2.3.2 应用场景 2.3.3 使用说明 2.3.4 项目截图 2.3.5 Snowflake雪花算法的代码实现 2.3 分布式ID 2.3.1 功能 ...

  10. 【云原生 · Kubernetes】部署高可用 kube-controller-manager 集群

    个人名片: 因为云计算成为了监控工程师‍ 个人博客:念舒_C.ying CSDN主页️:念舒_C.ying 部署高可用 kube-controller-manager 集群 12.1 创建 kube- ...