diff --git a/ios/App/App/CoachWorkoutKit.swift b/ios/App/App/CoachWorkoutKit.swift index 550daf9..2ce56aa 100644 --- a/ios/App/App/CoachWorkoutKit.swift +++ b/ios/App/App/CoachWorkoutKit.swift @@ -140,22 +140,14 @@ public class CoachWorkoutKitPlugin: CAPPlugin { // 7. Plan let plan = WorkoutPlan(.custom(custom)) - // 8. Request authorization si pas déjà accordée - let authState = await WorkoutScheduler.shared.authorizationState - if authState != .authorized { - _ = try await WorkoutScheduler.shared.requestAuthorization() - } - - // 9. Présenter la sheet système (iOS 17.4+) ou scheduler direct (17.0-17.3) - if #available(iOS 17.4, *) { - try await WorkoutScheduler.shared.preview(plan) - } else { - // Fallback : schedule "now" pour rendre dispo sur Watch - let now = Calendar.current.dateComponents( - [.year, .month, .day, .hour, .minute], - from: Date() - ) - _ = try await WorkoutScheduler.shared.schedule(plan, at: now) - } + // 8. Schedule pour "maintenant" — l'API la plus stable iOS 17.0+. + // Le workout devient immédiatement disponible dans Apple Watch → + // Exercice → Workouts personnalisés. Le 1er schedule déclenche la + // demande d'autorisation native si besoin. + let now = Calendar.current.dateComponents( + [.year, .month, .day, .hour, .minute], + from: Date() + ) + _ = try await WorkoutScheduler.shared.schedule(plan, at: now) } }