// // KegingIntents.swift // Keging // // 단축어 — "케겔 운동 시작" 하나. 앱을 열고 저장된 세팅대로 즉시 시작한다. // import AppIntents import Foundation struct StartKegelIntent: AppIntent { static var title: LocalizedStringResource = "케겔 운동 시작" static var description = IntentDescription("설정해 둔 수축·이완 사이클로 케겔 운동을 바로 시작해요.") static var openAppWhenRun: Bool = true @MainActor func perform() async throws -> some IntentResult { AppLaunchState.shared.startRequested = true NotificationCenter.default.post(name: .startWorkoutRequested, object: nil) return .result() } } struct KegingShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: StartKegelIntent(), phrases: [ "\(.applicationName) 시작", "\(.applicationName) 운동 시작", "\(.applicationName)에서 케겔 운동 시작" ], shortTitle: "케겔 운동 시작", systemImageName: "timer" ) } } extension Notification.Name { static let startWorkoutRequested = Notification.Name("startWorkoutRequested") } /// 단축어가 콜드 스타트로 앱을 열 때 알림보다 화면이 늦게 붙는 경합 대비 플래그 @MainActor final class AppLaunchState { static let shared = AppLaunchState() var startRequested = false private init() {} }