useEffect(() => {
// Check if HealthKit is available
AppleHealthKit?.isAvailable((err, available) => {
if (err || !available) {
Alert.alert(
"HealthKit Not Available",
"This device does not support Apple HealthKit."
);
return;
}
setIsHealthKitAvailable(true);
I dont know what am i missing here my library is installed properly ,pods are installed correctly but getting such error.
same error also there for isAvailable call.
Can anyone suggest or help me out to solve this issue?
import React, { useEffect, useState } from "react"; import { View, Text, Button, Alert } from "react-native"; import AppleHealthKit, { HealthKitPermissions } from "react-native-health";
const App = () => { const [isHealthKitAvailable, setIsHealthKitAvailable] = useState(false); const [hasPermissions, setHasPermission] = useState(false); const [steps, setSteps] = useState<number | null>(null);
const permissions: HealthKitPermissions = { permissions: { read: [AppleHealthKit.Constants.Permissions.Steps], write: [], }, };
const fetchSteps = () => { const options = { startDate: new Date(2024, 0, 1).toISOString(), // Example: fetch data from Jan 1, 2024 endDate: new Date().toISOString(), };
};
useEffect(() => { // Check if HealthKit is available AppleHealthKit?.isAvailable((err, available) => { if (err || !available) { Alert.alert( "HealthKit Not Available", "This device does not support Apple HealthKit." ); return; } setIsHealthKitAvailable(true);
}, []);
return ( <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
); };
export default App;
I dont know what am i missing here my library is installed properly ,pods are installed correctly but getting such error. same error also there for isAvailable call. Can anyone suggest or help me out to solve this issue?