feat: 支持原生模块健康数据

This commit is contained in:
richarjiang
2025-09-18 09:51:37 +08:00
parent 6b7776e51d
commit 6f0c872223
115 changed files with 1791 additions and 2851 deletions

View File

@@ -3,7 +3,7 @@
* React Native TypeScript bindings for iOS HealthKit access
*/
import { NativeModules } from 'react-native';
import { requireNativeModule } from 'expo-modules-core';
export interface HealthKitPermissions {
[key: string]: 'notDetermined' | 'denied' | 'authorized' | 'unknown';
@@ -50,6 +50,12 @@ export interface HealthKitManagerInterface {
*/
requestAuthorization(): Promise<HealthKitAuthorizationResult>;
/**
* Get current authorization status for HealthKit data types
* This checks the current permission status without prompting the user
*/
getAuthorizationStatus(): Promise<HealthKitAuthorizationResult>;
/**
* Get sleep analysis data from HealthKit
* @param options Query options including date range and limit
@@ -57,11 +63,8 @@ export interface HealthKitManagerInterface {
getSleepData(options?: SleepDataOptions): Promise<SleepDataResult>;
}
console.log('NativeModules', NativeModules);
// Native module interface
const HealthKitManager: HealthKitManagerInterface = NativeModules.HealthKitManager;
const HealthKitManager: HealthKitManagerInterface = requireNativeModule('HealthKitManager');
export default HealthKitManager;