forked from kingstinct/react-native-healthkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreModule.nitro.ts
More file actions
137 lines (118 loc) · 5.11 KB
/
CoreModule.nitro.ts
File metadata and controls
137 lines (118 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import type { HybridObject } from 'react-native-nitro-modules'
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<boolean>
/**
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery Apple Docs }
*/
disableBackgroundDelivery(
typeIdentifier: ObjectTypeIdentifier,
): Promise<boolean>
/**
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
*/
disableAllBackgroundDelivery(): Promise<boolean>
/**
* Configure background delivery types that will be registered natively in
* AppDelegate.didFinishLaunchingWithOptions — surviving app termination.
* Types and frequency are persisted to UserDefaults so they're available
* before the JS bridge boots on subsequent cold launches.
*
* Requires the Expo config plugin with `background: true` (default) or
* manual AppDelegate setup: `BackgroundDeliveryManager.shared.setupBackgroundObservers()`
*/
configureBackgroundTypes(
typeIdentifiers: string[],
updateFrequency: UpdateFrequency,
): Promise<boolean>
/**
* 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<boolean>
/**
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
*/
isHealthDataAvailable(): boolean
isHealthDataAvailableAsync(): Promise<boolean>
isProtectedDataAvailable(): boolean
isProtectedDataAvailableAsync(): Promise<boolean>
currentAppSource(): SourceProxy
getPreferredUnits(
identifiers: readonly QuantityTypeIdentifier[],
forceUpdate?: boolean,
): Promise<IdentifierWithUnit[]>
querySources(
identifier: SampleTypeIdentifier,
filter?: FilterForSamples,
): Promise<SourceProxy[]>
/** @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<boolean>
unsubscribeQueries(queryIds: string[]): number
unsubscribeQueriesAsync(queryIds: string[]): Promise<number>
/**
* 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<AuthorizationRequestStatus>
/**
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
*/
requestAuthorization(toRequest: AuthDataTypes): Promise<boolean>
requestPerObjectReadAuthorization(
typeIdentifier: PerObjectTypeIdentifier,
): Promise<void>
deleteObjects(
objectTypeIdentifier: SampleTypeIdentifierWriteable,
filter: FilterForSamples,
): Promise<number>
isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean
areObjectTypesAvailable(
objectTypeIdentifiers: readonly ObjectTypeIdentifier[],
): Record<string, boolean>
areObjectTypesAvailableAsync(
objectTypeIdentifiers: ObjectTypeIdentifier[],
): Promise<Record<string, boolean>>
isObjectTypeAvailableAsync(
objectTypeIdentifier: ObjectTypeIdentifier,
): Promise<boolean>
}