react-native-healthkit-bridge
Version:
A comprehensive React Native bridge for Apple HealthKit with TypeScript support, advanced authorization, and flexible data queries
56 lines (55 loc) • 2.41 kB
JavaScript
import { NativeModules } from 'react-native';
export class NativeHealthKitDataSource {
constructor() {
this.nativeModule = NativeModules.HealthKitBridge;
}
async requestAuthorization() {
return await this.nativeModule.requestAuthorization();
}
async requestSelectiveAuthorization(readTypes, writeTypes = []) {
return await this.nativeModule.requestSelectiveAuthorization(readTypes, writeTypes);
}
async getAuthorizationStatus(identifiers) {
const status = await this.nativeModule.getAuthorizationStatus(identifiers);
return status.map((item) => ({
identifier: item.identifier,
status: item.status
}));
}
async getAvailableTypes() {
return await this.nativeModule.getAvailableTypes();
}
async getTypeInfo(identifier) {
return await this.nativeModule.getTypeInfo(identifier);
}
async getQuantitySamplesForDays(identifier, unit, days) {
return await this.nativeModule.getQuantitySamplesForDays(identifier, unit, days);
}
async getCategorySamplesForDays(identifier, days) {
return await this.nativeModule.getCategorySamplesForDays(identifier, days);
}
async getWorkoutsForDays(days) {
return await this.nativeModule.getWorkoutsForDays(days);
}
async getQuantitySamplesForRange(identifier, unit, startDate, endDate) {
return await this.nativeModule.getQuantitySamplesForRange(identifier, unit, startDate, endDate);
}
async getCategorySamplesForRange(identifier, startDate, endDate) {
return await this.nativeModule.getCategorySamplesForRange(identifier, startDate, endDate);
}
async getWorkoutsForRange(startDate, endDate) {
return await this.nativeModule.getWorkoutsForRange(startDate, endDate);
}
async getQuantitySamplesWithRange(identifier, unit, startDate, endDate) {
return await this.nativeModule.getQuantitySamplesWithRange(identifier, unit, startDate, endDate);
}
async getCategorySamplesWithRange(identifier, startDate, endDate) {
return await this.nativeModule.getCategorySamplesWithRange(identifier, startDate, endDate);
}
async getWorkoutsWithRange(startDate, endDate) {
return await this.nativeModule.getWorkoutsWithRange(startDate, endDate);
}
isAvailable() {
return this.nativeModule.isAvailable();
}
}