Slide 17
Slide 17 text
コントロールの実装 - AppIntent -
struct SampleAppIntent: AppIntent {
static var openAppWhenRun: Bool = true
private(set) static var url: URL?
static func resetStoredURL() {
url = nil
}
@MainActor
func perform() async throws -> some IntentResult {
// カスタム URL スキーム
Self.url = URL(string: "sampleapp://")!
return .result()
}
}
17
func handle(urlSchemes: [any URLScheme]) -> Bool {
guard let url = SampleAppIntent.url else {
return false
}
SampleAppIntent.resetStoredURL()
for urlScheme in urlSchemes where urlScheme.canOpen(url: url) {
return true
}
return false
}
perform 関数の中で、static property として URL を渡す
アプリ起動処理時に SampleAppIntent.url をハンドリン
グして、期待した画⾯に遷移する
AppIntent App 本体