import type { HybridObject } from 'react-native-nitro-modules' import type { ActivitySummary, ActivitySummaryQueryFilter, } from '../types/ActivitySummary' import type { AuthorizationRequestStatus, AuthorizationStatus, } from '../types/Auth' import type { UpdateFrequency } from '../types/Background' import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier' import type { FilterForSamples } from '../types/QueryOptions' import type { ObjectTypeIdentifier, PerObjectTypeIdentifier, SampleTypeIdentifier, SampleTypeIdentifierWriteable, } from '../types/Shared' import type { OnChangeCallbackArgs } from '../types/Subscriptions' import type { IdentifierWithUnit } from '../types/Units' import type { SourceProxy } from './SourceProxy.nitro' export interface AuthDataTypes { toShare?: readonly SampleTypeIdentifierWriteable[] toRead?: readonly ObjectTypeIdentifier[] } export interface CoreModule extends HybridObject<{ ios: 'swift' }> { /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs } */ enableBackgroundDelivery( typeIdentifier: ObjectTypeIdentifier, updateFrequency: UpdateFrequency, ): Promise /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery Apple Docs } */ disableBackgroundDelivery( typeIdentifier: ObjectTypeIdentifier, ): Promise /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs } */ disableAllBackgroundDelivery(): Promise /** * Configure background delivery types whose observer queries are registered * natively at launch (during didFinishLaunchingWithOptions), so background * delivery survives app termination. * Types and frequency are persisted to UserDefaults so they're available * before the JS bridge boots on subsequent cold launches. * * Requires the background-delivery entitlement (added by the config plugin * unless `background: false`). No AppDelegate change is needed; the pod * registers the observers on UIApplicationDidFinishLaunchingNotification. */ configureBackgroundTypes( typeIdentifiers: string[], updateFrequency: UpdateFrequency, ): Promise /** * Clear persisted background delivery configuration and stop all observer queries. * After calling this, the app will no longer register observers on cold launch. */ clearBackgroundTypes(): Promise /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs } */ isHealthDataAvailable(): boolean isHealthDataAvailableAsync(): Promise isProtectedDataAvailable(): boolean isProtectedDataAvailableAsync(): Promise currentAppSource(): SourceProxy getPreferredUnits( identifiers: readonly QuantityTypeIdentifier[], forceUpdate?: boolean, ): Promise querySources( identifier: SampleTypeIdentifier, filter?: FilterForSamples, ): Promise /** @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-requestauthorizationtoaccess Apple Docs } * @param {SampleTypeIdentifier} typeIdentifier - The type identifier of the sample to request authorization for. * @param {(args: OnChangeCallbackArgs) => void} callback - An array of type identifiers that the app wants to write. * @returns A promise that resolves to a boolean indicating whether the authorization was successful.*/ subscribeToObserverQuery( typeIdentifier: SampleTypeIdentifier, callback: (args: OnChangeCallbackArgs) => void, ): string unsubscribeQuery(queryId: string): boolean unsubscribeQueryAsync(queryId: string): Promise unsubscribeQueries(queryIds: string[]): number unsubscribeQueriesAsync(queryIds: string[]): Promise /** * Returns the app’s authorization status for sharing the specified data type. * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs } */ authorizationStatusFor(type: ObjectTypeIdentifier): AuthorizationStatus /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs } */ getRequestStatusForAuthorization( toCheck: AuthDataTypes, ): Promise /** * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs } */ requestAuthorization(toRequest: AuthDataTypes): Promise requestPerObjectReadAuthorization( typeIdentifier: PerObjectTypeIdentifier, ): Promise /** * Reports, for each of the given object types, the earliest date from which the app is * authorized to read samples when the user has granted only limited access. * * A type is only present in the result when the user has imposed a lower time bound on * the app's read access for it - types without such a bound are omitted. Use it to clamp * the `startDate` of a query filter so you don't request data you can't read. * * Requires iOS 27. On earlier versions there is no limited-access lower bound, so this * resolves to an empty object. It also resolves to an empty object - and logs a warning - * when running on iOS 27 in an app built with an SDK older than iOS 27, since the * underlying API cannot be called from such a binary. * * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/earliestauthorizedsampledate(for:) Apple Docs } */ getEarliestAuthorizedSampleDates( objectTypeIdentifiers: readonly ObjectTypeIdentifier[], ): Promise> deleteObjects( objectTypeIdentifier: SampleTypeIdentifierWriteable, filter: FilterForSamples, ): Promise isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean areObjectTypesAvailable( objectTypeIdentifiers: readonly ObjectTypeIdentifier[], ): Record areObjectTypesAvailableAsync( objectTypeIdentifiers: ObjectTypeIdentifier[], ): Promise> isObjectTypeAvailableAsync( objectTypeIdentifier: ObjectTypeIdentifier, ): Promise /** * Queries activity summary objects from HealthKit. * @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummaryquery Apple Docs HKActivitySummaryQuery} */ queryActivitySummary( filter?: ActivitySummaryQueryFilter, ): Promise }