feat(watchos): message clair si accès Santé refusé (au lieu de Error(7))
Si authorizationStatus(workoutType) == .sharingDenied après requestAuthorization, on n'essaie pas de démarrer la séance (qui échouerait en HKErrorAuthorizationDenied) et on affiche un message demandant d'activer Coach dans Réglages → Santé. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,10 @@ final class WorkoutManager: NSObject, ObservableObject {
|
|||||||
try await healthStore.requestAuthorization(toShare: share, read: read)
|
try await healthStore.requestAuthorization(toShare: share, read: read)
|
||||||
let woStatus = healthStore.authorizationStatus(for: HKQuantityType.workoutType())
|
let woStatus = healthStore.authorizationStatus(for: HKQuantityType.workoutType())
|
||||||
workoutLog.info("requestAuthorization OK; workoutType share status=\(woStatus.rawValue)")
|
workoutLog.info("requestAuthorization OK; workoutType share status=\(woStatus.rawValue)")
|
||||||
|
if woStatus == .sharingDenied {
|
||||||
|
statusMessage = "Accès Santé refusé. Active Coach dans Réglages → Santé → Accès aux données, puis relance."
|
||||||
|
return
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
workoutLog.error("requestAuthorization threw: \(error.localizedDescription)")
|
workoutLog.error("requestAuthorization threw: \(error.localizedDescription)")
|
||||||
statusMessage = "Autorisation Santé refusée : \(error.localizedDescription)"
|
statusMessage = "Autorisation Santé refusée : \(error.localizedDescription)"
|
||||||
|
|||||||
Reference in New Issue
Block a user