Question

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?

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

Was it helpful?

Solution

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.

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.

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.

This code works for me (iOS 6.1):

#import "GSEvent.h"

and

- (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);  
}

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.

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

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

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.

OTHER TIPS

Nope. No access to Siri. I am pretty sure that if you do get access, somehow, Apple will reject your app. (but I can think of many more who will be appreciative)

There is this, though: http://ps3trophies.com/forums/apple/6458-siri-cracked-now-even-android-users-can-use-siri.html

See this answer as well:https://stackoverflow.com/a/12607905/2535467

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top