我一直在寻找,但还没有找到......你知道是否有办法 确定我的 iOS 应用程序是由 Siri 启动的还是由用户点击应用程序图标启动的?
我需要知道,因为我只想在我的应用启动时自动执行启动操作 从 Siri 启动。
我在想也许 application:didFinishLaunchingWithOptions 或者 其他一些 API 可以让我的应用知道它是如何启动的,但事实并非如此 似乎是这样(或者我只是错过了)。
知道在 Apple 发布之前是否有可用的技巧 一些官方/公开的 Siri API?
最佳答案
我唯一可以建议的是检查作为 application:willFinishLaunchingWithOptions:
和 application:didFinishLaunchingWithOptions:
的一部分传入的 launchOption 字典。
有一个键声称会列出请求您的应用程序启动的应用程序的名称,并且可能会列出 Siri:
来自位于 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.
关于ios - 确定 iOS 应用程序是否通过 Siri 启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19149587/