Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining whether iOS application was launched via Siri

I've been looking forever, but haven't found… Do you know if there's a way to determine whether my iOS app was launched by Siri or by the user tapping the app icon?

I need to know because I want to automate a startup action only when my app is launched from Siri.

I was thinking that maybe application:didFinishLaunchingWithOptions or some other API would allow my app to know how it was launched, but that doesn't seem to be the case (or I just missed it).

Any idea if there's some trick available that I could use until Apple publishes some official/public Siri API ?

like image 545
Yan Avery Avatar asked Oct 03 '13 01:10

Yan Avery


1 Answers

The only thing I can suggest is to check the launchOption dictionary passed in as part of application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions:.

There is one key that claims to list the name of the application that requested your apps launch and maybe Siri would be listed:

From the apple doc located here:

UIApplicationLaunchOptionsSourceApplicationKey

The presence of this key identifies the app that requested the launch of your app. The value of this key is an NSString object that represents the bundle ID of the app that made the request. This key is also used to access the same value in the userInfo dictionary of the notification named UIApplicationDidFinishLaunchingNotification. Available in iOS 3.0 and later. Declared in UIApplication.h.

like image 117
Dean Avatar answered Sep 20 '22 05:09

Dean