确定iOS应用程序是否通过Siri启动 [英] Determining whether iOS application was launched via Siri

查看:161
本文介绍了确定iOS应用程序是否通过Siri启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找永远,但没有找到...你知道如果有一个方法
确定我的iOS应用程序是由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?

我需要知道,因为我想自动化一个启动动作,只有当我的应用程序是从Siri启动

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

我一直在想,也许应用程序:didFinishLaunchingWithOptions
一些其他API将允许我的应用程序知道如何启动,但不是
似乎是这种情况

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).

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

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

推荐答案

我唯一可以建议的是检查作为应用程序的一部分传递的launchOption字典:willFinishLaunchingWithOptions: / code>和应用程序:didFinishLaunchingWithOptions:

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

有一个键声明列出请求您的应用程序启动的应用程序的名称,也许Siri将被列出:

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

从位于此处

UIApplicationLaunchOptionsSourceApplicationKey


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

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应用程序是否通过Siri启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆