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

标签 ios objective-c cocoa-touch siri

我一直在寻找,但还没有找到......你知道是否有办法 确定我的 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/

相关文章:

ios - 删除行后 UITableview 重新加载数据

ios - 云包 "Your request contains more than the maximum number of items in a single request (400)"

ios - Swift 中的 UIView 动画不起作用,参数错误

ios - 导入gradle插件生成的cocoapods时,Xcode显示快速的编译器错误

ios - 在 UIViewController 中展开和折叠 UIView

ios - 提取并显示 IOS 设备的信息

ios - NSURLSession 返回数据

objective-c - 使用 GestureRecognizers 操作 UIImage - NOT UIImageView

iphone - "_OBJC_CLASS_$_CATransaction, referenced from:"编译时错误是什么意思?

ios - 如何获取 bool 值 isTouching 或触摸 iOS