diff --git a/src/HealthKit/HKAppleSleepingBreathingDisturbances.cs b/src/HealthKit/HKAppleSleepingBreathingDisturbances.cs new file mode 100644 index 000000000000..2a41f4276131 --- /dev/null +++ b/src/HealthKit/HKAppleSleepingBreathingDisturbances.cs @@ -0,0 +1,44 @@ +using System; +using System.Runtime.InteropServices; +using ObjCRuntime; +using Foundation; +using HKQuantityRef = System.IntPtr; +using NSErrorRef = System.IntPtr; + +#nullable enable + +namespace HealthKit { + + [SupportedOSPlatform ("ios18.0")] + [SupportedOSPlatform ("maccatalyst18.0")] + [SupportedOSPlatform ("macos15.0")] + [UnsupportedOSPlatform ("tvos")] + public static class HKAppleSleepingBreathingDisturbances { + + [DllImport (Constants.HealthKitLibrary)] + unsafe static extern /* NSNumber * _Nullable */ IntPtr HKAppleSleepingBreathingDisturbancesClassificationForQuantity (HKQuantityRef value); + + /// Get the breathing disturbances classification for a given quantity of breathing disturbance. + /// The quantity of the breathing disturbance whose classification to get. + /// The breathing disturbances classification for the specified breathing disturbance quantity. + public static HKAppleSleepingBreathingDisturbancesClassification? GetClassification (HKQuantity value) + { + var ptr = HKAppleSleepingBreathingDisturbancesClassificationForQuantity (value.GetHandle ()); + var number = Runtime.GetNSObject (ptr); + if (number is null) + return null; + return (HKAppleSleepingBreathingDisturbancesClassification) number.LongValue; + } + + [DllImport (Constants.HealthKitLibrary)] + static extern HKQuantityRef HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification (nint /* HKAppleSleepingBreathingDisturbancesClassification */ classification); + + /// Get the minimum quantity for a breathing disturbances classification. + /// The classification to get the minimum quantity for. + /// The minimum quantity for the specified breathing disturbances classification. + public static HKQuantity? GetMinimumQuantity (HKAppleSleepingBreathingDisturbancesClassification classification) + { + return Runtime.GetNSObject (HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification ((nint) (long) classification)); + } + } +} diff --git a/src/frameworks.sources b/src/frameworks.sources index af3c7581db6d..4de299e162b0 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1012,6 +1012,7 @@ HEALTHKIT_API_SOURCES = \ HEALTHKIT_SOURCES = \ HealthKit/EnumsCompat.cs \ + HealthKit/HKAppleSleepingBreathingDisturbances.cs \ HealthKit/HKAppleWalkingSteadiness.cs \ HealthKit/HKAnchoredObjectQuery.cs \ HealthKit/HKCategoryValueSleepAnalysisAsleep.cs \ diff --git a/src/healthkit.cs b/src/healthkit.cs index 150124aadd85..a744f7e67e52 100644 --- a/src/healthkit.cs +++ b/src/healthkit.cs @@ -2696,6 +2696,10 @@ enum HKQuantityTypeIdentifier { [iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)] [Field ("HKQuantityTypeIdentifierRowingSpeed")] RowingSpeed, + + [iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)] + [Field ("HKQuantityTypeIdentifierAppleSleepingBreathingDisturbances")] + AppleSleepingBreathingDisturbances, } /// Contains constants that identify HealthKit correlation types. @@ -3048,6 +3052,10 @@ enum HKCategoryTypeIdentifier { [iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)] [Field ("HKCategoryTypeIdentifierBleedingDuringPregnancy")] BleedingDuringPregnancy, + + [iOS (18, 0), MacCatalyst (18, 0), Mac (15, 0), Watch (11, 0)] + [Field ("HKCategoryTypeIdentifierSleepApneaEvent")] + SleepApneaEvent, } /// Enumerates the forms of . @@ -5311,4 +5319,12 @@ interface HKWorkoutEffortRelationshipQuery { [Export ("initWithPredicate:anchor:options:resultsHandler:")] NativeHandle Constructor ([NullAllowed] NSPredicate predicate, [NullAllowed] HKQueryAnchor anchor, HKWorkoutEffortRelationshipQueryOptions options, HKWorkoutEffortRelationshipQueryResultsHandler resultsHandler); } + + [Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)] + [Native] + public enum HKAppleSleepingBreathingDisturbancesClassification : long { + NotElevated, + Elevated, + } + } diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt index b4ef706ffdaa..7ed397a3a0e7 100644 --- a/tests/cecil-tests/Documentation.KnownFailures.txt +++ b/tests/cecil-tests/Documentation.KnownFailures.txt @@ -10853,6 +10853,8 @@ F:HealthKit.HKActivityMoveMode.AppleMoveTime F:HealthKit.HKAnchoredObjectQuery.NoAnchor F:HealthKit.HKAppleEcgAlgorithmVersion.Version1 F:HealthKit.HKAppleEcgAlgorithmVersion.Version2 +F:HealthKit.HKAppleSleepingBreathingDisturbancesClassification.Elevated +F:HealthKit.HKAppleSleepingBreathingDisturbancesClassification.NotElevated F:HealthKit.HKAppleWalkingSteadinessClassification.Low F:HealthKit.HKAppleWalkingSteadinessClassification.Ok F:HealthKit.HKAppleWalkingSteadinessClassification.VeryLow @@ -10951,6 +10953,7 @@ F:HealthKit.HKCategoryTypeIdentifier.ShortnessOfBreath F:HealthKit.HKCategoryTypeIdentifier.SinusCongestion F:HealthKit.HKCategoryTypeIdentifier.SkippedHeartbeat F:HealthKit.HKCategoryTypeIdentifier.SleepAnalysis +F:HealthKit.HKCategoryTypeIdentifier.SleepApneaEvent F:HealthKit.HKCategoryTypeIdentifier.SleepChanges F:HealthKit.HKCategoryTypeIdentifier.SoreThroat F:HealthKit.HKCategoryTypeIdentifier.ToothbrushingEvent @@ -11161,6 +11164,7 @@ F:HealthKit.HKQuantityAggregationStyle.DiscreteTemporallyWeighted F:HealthKit.HKQuantityTypeIdentifier.ActiveEnergyBurned F:HealthKit.HKQuantityTypeIdentifier.AppleExerciseTime F:HealthKit.HKQuantityTypeIdentifier.AppleMoveTime +F:HealthKit.HKQuantityTypeIdentifier.AppleSleepingBreathingDisturbances F:HealthKit.HKQuantityTypeIdentifier.AppleSleepingWristTemperature F:HealthKit.HKQuantityTypeIdentifier.AppleStandTime F:HealthKit.HKQuantityTypeIdentifier.AppleWalkingSteadiness @@ -83756,6 +83760,8 @@ T:GLKit.GLKViewDrawEventArgs T:HealthKit.HKActivityMoveMode T:HealthKit.HKAnchoredObjectUpdateHandler T:HealthKit.HKAppleEcgAlgorithmVersion +T:HealthKit.HKAppleSleepingBreathingDisturbances +T:HealthKit.HKAppleSleepingBreathingDisturbancesClassification T:HealthKit.HKAppleWalkingSteadiness T:HealthKit.HKAppleWalkingSteadinessClassification T:HealthKit.HKAttachmentStoreCompletionHandler diff --git a/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs b/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs index d6f511b967ea..9a164cce6b4d 100644 --- a/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs +++ b/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs @@ -136,6 +136,7 @@ public void EnumValues_22351 () case HKCategoryTypeIdentifier.BleedingAfterPregnancy: case HKCategoryTypeIdentifier.BleedingDuringPregnancy: + case HKCategoryTypeIdentifier.SleepApneaEvent: if (!TestRuntime.CheckXcodeVersion (16, 0)) continue; break; diff --git a/tests/monotouch-test/HealthKit/HKAppleSleepingBreathingDisturbancesTest.cs b/tests/monotouch-test/HealthKit/HKAppleSleepingBreathingDisturbancesTest.cs new file mode 100644 index 000000000000..3f8bb8b81421 --- /dev/null +++ b/tests/monotouch-test/HealthKit/HKAppleSleepingBreathingDisturbancesTest.cs @@ -0,0 +1,27 @@ +#if HAS_HEALTHKIT + +using System; + +using Foundation; +using HealthKit; + +using NUnit.Framework; + +namespace MonoTouchFixtures.HealthKit { + + [TestFixture] + [Preserve (AllMembers = true)] + public class HKAppleSleepingBreathingDisturbancesTest { + [Test] + public void RoundtripTest () + { + TestRuntime.AssertXcodeVersion (16, 0); + + var minimum = HKAppleSleepingBreathingDisturbances.GetMinimumQuantity (HKAppleSleepingBreathingDisturbancesClassification.Elevated); + var classification = HKAppleSleepingBreathingDisturbances.GetClassification (minimum); + Assert.AreEqual (HKAppleSleepingBreathingDisturbancesClassification.Elevated, classification, "Classification"); + } + } +} + +#endif // HAS_HEALTHKIT diff --git a/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs b/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs index e96db6d22c6a..1a2293f819f1 100644 --- a/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs +++ b/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs @@ -125,6 +125,7 @@ public void EnumValues_22351 () if (!TestRuntime.CheckXcodeVersion (15, 0)) continue; break; + case HKQuantityTypeIdentifier.AppleSleepingBreathingDisturbances: case HKQuantityTypeIdentifier.CrossCountrySkiingSpeed: case HKQuantityTypeIdentifier.DistanceCrossCountrySkiing: case HKQuantityTypeIdentifier.DistancePaddleSports: diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-HealthKit.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-HealthKit.todo deleted file mode 100644 index 409e18c38bb9..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-HealthKit.todo +++ /dev/null @@ -1,5 +0,0 @@ -!missing-enum! HKAppleSleepingBreathingDisturbancesClassification not bound -!missing-field! HKCategoryTypeIdentifierSleepApneaEvent not bound -!missing-field! HKQuantityTypeIdentifierAppleSleepingBreathingDisturbances not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesClassificationForQuantity is not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-HealthKit.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-HealthKit.todo deleted file mode 100644 index 409e18c38bb9..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-HealthKit.todo +++ /dev/null @@ -1,5 +0,0 @@ -!missing-enum! HKAppleSleepingBreathingDisturbancesClassification not bound -!missing-field! HKCategoryTypeIdentifierSleepApneaEvent not bound -!missing-field! HKQuantityTypeIdentifierAppleSleepingBreathingDisturbances not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesClassificationForQuantity is not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-HealthKit.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-HealthKit.todo deleted file mode 100644 index 409e18c38bb9..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-HealthKit.todo +++ /dev/null @@ -1,5 +0,0 @@ -!missing-enum! HKAppleSleepingBreathingDisturbancesClassification not bound -!missing-field! HKCategoryTypeIdentifierSleepApneaEvent not bound -!missing-field! HKQuantityTypeIdentifierAppleSleepingBreathingDisturbances not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesClassificationForQuantity is not bound -!missing-pinvoke! HKAppleSleepingBreathingDisturbancesMinimumQuantityForClassification is not bound