15

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?

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

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

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

4

3 に答える 3

2

application:willFinishLaunchingWithOptions:私が提案できる唯一のことは、 andの一部として渡された launchOption ディクショナリを確認することですapplication:didFinishLaunchingWithOptions:

アプリの起動を要求したアプリケーションの名前を一覧表示すると主張する 1 つのキーがあり、おそらく Siri が一覧表示されます。

ここにあるアップルのドキュメントから:

UIApplicationLaunchOptionsSourceApplicationKey

このキーの存在により、アプリの起動を要求したアプリが識別されます。このキーの値は、リクエストを行ったアプリのバンドル ID を表す NSString オブジェクトです。このキーは、UIApplicationDidFinishLaunchingNotification という名前の通知の userInfo ディクショナリ内の同じ値にアクセスするためにも使用されます。iOS 3.0 以降で利用できます。UIApplication.h で宣言されています。

于 2013-11-14T19:09:39.303 に答える
0

Apple が提供する起動オプションのリスト

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

Apple のドキュメントLaunch Options Keysへのリンクは次のとおりです。
公式/公開の Siri API Quora Linkに関する Quora へのリンクは次のとおりです。

于 2016-02-11T05:48:02.453 に答える
0

Siri から起動すると、application:didFinishLaunchingWithOptions が呼び出されます。ただし、私の launchOptions 辞書は空です。URL スキームを使用してアプリを起動すると、launchOptions ディクショナリに適切なキーが含まれます。現時点では、アプリが Siri から起動されたかどうかを知ることはできないようです

于 2016-02-08T19:17:26.513 に答える