确定iOS应用程序是否通过Siri启动

我一直在寻找永远,但还没有find…你知道是否有方法来确定我的iOS应用程序是由Siri发起还是由用户点击应用程序图标?

我需要知道,因为我只想在我的应用程序从Siri启动时自动执行启动操作。

我在想,也许应用程序:didFinishLaunchingWithOptions或一些其他API将允许我的应用程序知道它是如何启动的,但似乎并非如此(或者我错过了它)。

任何想法,如果有一些技巧,我可以使用,直到苹果公布一些官方/公开的Siri API?

我可以build议的唯一的事情是检查作为application:willFinishLaunchingWithOptions:一部分传入的launchOption字典application:willFinishLaunchingWithOptions:application:didFinishLaunchingWithOptions: application:willFinishLaunchingWithOptions:

有一个关键要求列出请求启动应用程序的应用程序的名称,也许Siri会被列出:

从位于这里的苹果文件:

UIApplicationLaunchOptionsSourceApplicationKey

此密钥的存在标识请求启动您的应用程序的应用程序。 此键的值是一个NSString对象,表示发出请求的应用程序的包ID。 此键也用于访问名为UIApplicationDidFinishLaunchingNotification的通知的userInfo字典中的相同值。 在iOS 3.0及更高版本中可用。 在UIApplication.h中声明。

当我从Siri启动时,应用程序:didFinishLaunchingWithOptions被调用。 但是,我的launchOptions字典是空的。 如果我使用URLscheme启动应用程序,则我的launchOptions字典具有相应的键。 目前,看起来不太可能知道该应用是否是从Siri发布的

苹果提供的启动选项列表

let UIApplicationLaunchOptionsURLKey: String let UIApplicationLaunchOptionsSourceApplicationKey: String let UIApplicationLaunchOptionsRemoteNotificationKey: String let UIApplicationLaunchOptionsLocalNotificationKey: String let UIApplicationLaunchOptionsAnnotationKey: String let UIApplicationLaunchOptionsLocationKey: String let UIApplicationLaunchOptionsNewsstandDownloadsKey: String let UIApplicationLaunchOptionsBluetoothCentralsKey: String let UIApplicationLaunchOptionsBluetoothPeripheralsKey: String let UIApplicationLaunchOptionsShortcutItemKey: String let UIApplicationLaunchOptionsUserActivityDictionaryKey: String let UIApplicationLaunchOptionsUserActivityTypeKey: String

这里是苹果的文档启动选项键的链接。
这里是关于官方/公开Siri API Quora Link的Quora的链接