可以使用私有API在我的应用程序中以编程方式调用Siri吗? [英] Can Siri be invoked programmatically within my app using private APIs?

查看:175
本文介绍了可以使用私有API在我的应用程序中以编程方式调用Siri吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以编程方式在我的应用程序中启动Siri,而不是让用户按住主页按钮。由于没有可用于实现此目的的公共API,我想知道,如果有人能够通过私有API以编程方式启动Siri,那么您使用哪个私有API?

Instead of having the user to hold the home button, I would like to programmatically launch Siri within my application. Since there are no public APIs available to accomplish this, I would like to know, if anybody has been able to programmatically launch Siri via private API and if so which private API did you use?

我对Siri的任何回报值不感兴趣。我想做的就是启动它。

I am not interested in any return values from Siri. All I want to do is to launch it.

推荐答案

答案取决于是否适用于刚赢得的应用不要去App Store(企业应用程序或个人/爱好应用程序),或者它是否真的会在越狱手机上运行。

The answer depends a bit on whether this is for an app that just won't go to the App Store (enterprise app, or personal/hobby app), or whether it will actually be run on jailbroken phones.

如果您可以依赖越狱手机和越狱实用程序(如MobileSubstrate),那么我相信您可以实现一种方法来打开Siri,就像 Ryan Petrich的libActivator确实,因为我在其他答案中显示

If you can rely on a jailbroken phone, and jailbreak utilities like MobileSubstrate, then I believe you can implement a method to open Siri just like Ryan Petrich's libActivator does, as I show in this other answer.

但是,如果您正在构建普通的 jailed 手机,我仍然认为您可以破解它(使用私有API) ,通过模拟用户打开Siri的方式。首先,按Home键,按住一下,然后释放它。

However, if you are building for normal, jailed phones, I still think you can "hack" it (with Private APIs), by simulating the way the user opens Siri. First, press the Home button, hold it for a bit, then release it.

此代码适用于我(iOS 6.1):

This code works for me (iOS 6.1):

#import "GSEvent.h"

- (void)launchSiri {
   [self simulateTouchEvent: kGSEventMenuButtonDown];

   double delayInSeconds = 1.0;
   dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
   dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
      [self simulateTouchEvent: kGSEventMenuButtonUp];
   });
}

- (void)simulateTouchEvent: (GSEventType)type
{
   struct GSEventRecord record;
   memset(&record, 0, sizeof(record));
   record.type = type;
   record.timestamp = GSCurrentEventTimestamp();
   GSSendSystemEvent(&record);  
}

这取决于拥有GSEvent.h标头,它不属于公共标题集。我相信我得到了我的这里,以及GSWindow。 h它拉入。显然,您需要下载这两个标题并将它们添加到您的项目中。

This relies on having the GSEvent.h header, which isn't part of the public set of headers. I believe I got mine here, as well as GSWindow.h that it pulls in. Obviously, you'd then need to download these two headers and add them to your project.

此代码位于 GraphicsServices 私有框架中,所以你还需要将该框架添加到你的项目中。这样做就像添加一个普通框架一样,但你需要浏览到某个地方,比如

This code is in the GraphicsServices private framework, so you'll also need to add that framework to your project. Do so just like adding a normal framework, but you need to browse to somewhere like

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/PrivateFrameworks/GraphicsServices.framework

查找它(为你的Xcode安装目录调整路径,以及SDK)。

to find it (path adjusted for your Xcode installation directory, and SDK).

免责声明:我在越狱手机上测试了这个,但绝对是在一个普通的应用程序中,安装在 / var / mobile / Applications / 沙箱区域,我99%肯定我没有做任何取决于被越狱的事情。

Disclaimer: I did test this on a jailbroken phone, but it was definitely inside a normal app, installed in the /var/mobile/Applications/ sandbox area, and I'm 99% sure I haven't done anything that depends on being jailbroken.

这篇关于可以使用私有API在我的应用程序中以编程方式调用Siri吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆