我找了很久,但没有发现...你知道有没有办法确定我的iOS应用是通过Siri还是用户点击应用程序图标启动的吗?
我需要知道这一点,因为我只想在从Siri启动我的应用程序时自动执行启动操作。
我想也许application:didFinishLaunchingWithOptions或其他API可以让我的应用程序知道它是如何启动的,但似乎并非如此(或者我只是错过了)。
是否有什么技巧可用,以便我在Apple发布官方/公共Siri API之前使用?
我找了很久,但没有发现...你知道有没有办法确定我的iOS应用是通过Siri还是用户点击应用程序图标启动的吗?
我需要知道这一点,因为我只想在从Siri启动我的应用程序时自动执行启动操作。
我想也许application:didFinishLaunchingWithOptions或其他API可以让我的应用程序知道它是如何启动的,但似乎并非如此(或者我只是错过了)。
是否有什么技巧可用,以便我在Apple发布官方/公共Siri API之前使用?
application:willFinishLaunchingWithOptions:
和 application:didFinishLaunchingWithOptions:
的一部分传递的 launchOption 字典。有一个键声称列出了请求您的应用程序启动的应用程序名称,也许Siri会被列出:UIApplicationLaunchOptionsSourceApplicationKey
此键的存在标识请求启动您的应用程序的应用程序。此键的值是表示发出请求的应用程序的包ID的NSString对象。
此键还用于在名为UIApplicationDidFinishLaunchingNotification的通知的userInfo字典中访问相同的值。
在iOS 3.0及更高版本中可用。
声明在UIApplication.h中。苹果提供的启动选项列表
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
这里是苹果文档中关于启动选项键的链接 Launch Options Keys。
这里是关于官方/公共Siri API的Quora链接 Quora Link