質問編集履歴
2
補足の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Siriにアプリ名を言って起動したのか普通にアイコンをタップして起動したのかを識別したいです。
|
2
|
-
下記の質問を参考にしたのですがuserActivityDictionary?[.userActivityType]がSiriで起動してもnilのままで識別できないです。
|
2
|
+
下記の質問を参考にしたのですが「userActivityDictionary?[.userActivityType]」がSiriで起動してもnilのままで識別できないです。
|
3
3
|
[viewControllerでSiriショートカット起動か、通常クリック起動かの識別](https://teratail.com/questions/171454)
|
4
4
|
|
5
|
-
こちらが試したコードです
|
5
|
+
こちらが試したコードです。
|
6
6
|
MainMenuVC.swift
|
7
|
-
```
|
7
|
+
```swift5
|
8
8
|
import UIKit
|
9
9
|
|
10
10
|
class MainMenuVC: UIViewController {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
}
|
30
30
|
```
|
31
31
|
AppDelegate.swift
|
32
|
-
```
|
32
|
+
```swift5
|
33
33
|
import UIKit
|
34
34
|
|
35
35
|
@main
|
@@ -38,7 +38,7 @@
|
|
38
38
|
var siriStart:Int = 0
|
39
39
|
|
40
40
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
41
|
-
|
41
|
+
|
42
42
|
print("didFinishLaunchingWithOptions")
|
43
43
|
|
44
44
|
let userActivityDictionary = launchOptions?[.userActivityDictionary] as? [UIApplication.LaunchOptionsKey : Any]
|
@@ -46,24 +46,22 @@
|
|
46
46
|
siriStart = 1
|
47
47
|
}
|
48
48
|
return true
|
49
|
-
|
50
49
|
}
|
51
50
|
|
52
|
-
|
51
|
+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
53
52
|
|
54
|
-
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
55
|
-
// Called when a new scene session is being created.
|
56
|
-
// Use this method to select a configuration to create the new scene with.
|
57
53
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
58
54
|
}
|
59
55
|
|
60
56
|
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
61
|
-
|
57
|
+
|
62
|
-
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
63
|
-
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
64
58
|
}
|
65
59
|
|
66
60
|
}
|
67
61
|
```
|
68
62
|
上記コードを実行してもappDelegate.siriStart=0のままでViewControllerでSiriを識別することができないです。
|
69
|
-
どうすれば良いでしょうか、ご教授よろしくお願い致します。
|
63
|
+
どうすれば良いでしょうか、ご教授よろしくお願い致します。
|
64
|
+
|
65
|
+
※補足
|
66
|
+
AppDelegateにDelegate関数を全て記述してSiriショートカット起動時のみに呼ばれる関数がないか調べてみましたがありませんでした。
|
67
|
+
参考にした質問ではSwift3だったのでSwift5になったためにできなくなったかもしれないです。
|
1
タイトルの変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Siriショートカット起動か通常
|
1
|
+
Siriショートカット起動か通常タップ起動かの識別
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Siriにアプリ名を言って起動したのか普通にアイコンタップして起動したのかを識別したいです。
|
1
|
+
Siriにアプリ名を言って起動したのか普通にアイコンをタップして起動したのかを識別したいです。
|
2
2
|
下記の質問を参考にしたのですがuserActivityDictionary?[.userActivityType]がSiriで起動してもnilのままで識別できないです。
|
3
3
|
[viewControllerでSiriショートカット起動か、通常クリック起動かの識別](https://teratail.com/questions/171454)
|
4
4
|
|