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. jsp中使用Servlet查询SQLSERVER数据库中的表的信息,并且打印在屏幕上

    jsp中使用Servlet查询SQLSERVER数据库中的表的信息,并且打印在屏幕上 1.JavaBean的使用 package com.zheng; public class BookBean { ...

  2. 《吐血整理》高级系列教程-吃透Fiddler抓包教程(29)-Fiddler如何抓取Android7.0以上的Https包-终篇

    1.简介 上一篇宏哥介绍的Xposed是一款可以在不修改APK的情况下影响程序运行的框架.可以编写并加载自己编写的插件app,实现对目标apk的注入.拦截等.一般研究移动安全的都会使用Xposed. ...

  3. java中GC的日志认识详解

    不同的垃圾回收器 他们的日志都是完成不一样的,看懂日志是解决和发现问题的重中之重. Parallel Scavenge + Parallel Old 日志 启动参数 -XX:+UseParallelG ...

  4. .NET API 接口数据传输加密最佳实践

    .NET API 接口数据传输加密最佳实践 我们在做 Api 接口时,相信一定会有接触到要给传输的请求 body 的内容进行加密传输.其目的就是为了防止一些敏感的内容直接被 UI 层查看或篡改. 其实 ...

  5. <六>指向类成员的指针

    指向类成员(成员变量和成员方法)的指针 1:定义一个指针指向类的普通成员变量 示例代码1 点击查看代码 class Test2{ public: int ma; static int mb; void ...

  6. 2022春每日一题:Day 12

    题目:[SDOI2006]线性方程组 显然,高斯消元模板题 代码: #include <cstdio> #include <cstdlib> #include <cstr ...

  7. Go语言核心36讲43-----io包中接口的好处与优势

    上一篇文章中,我主要讲到了io.Reader的扩展接口和实现类型.当然,io代码包中的核心接口不止io.Reader一个. 我们基于它引出的一条主线,只是io包类型体系中的一部分.我们很有必要再从另一 ...

  8. 关于phalcon框架中DI的理解

    DI(依赖注入) https://www.imooc.com/learn/867 https://www.imooc.com/learn/912

  9. windows10 设置VS一类的不提供兼容性视图的程序默认管理员启动

    选择兼容性疑难解答: 选择疑难解答程序: 下一步后保存即可.

  10. 使用 Rainbond 搭建本地开发环境

    在开发之前,你需要在本地安装各种开发工具和服务,比如:Mysql.Redis.Nacos 等等,我们都知道在个人电脑上安装这些服务相当的繁琐,可能会遇到很多问题,环境问题.依赖问题等等. 在需要团队协 ...