rn-samsung-health
rn-samsung-health copied to clipboard
TypeError: Cannot read property 'getConstants' of null
import { useState } from 'react'
import { Button, Text } from 'react-native'
import { SafeAreaView } from 'react-native'
import RNSamsungHealth from 'rn-samsung-health'
export default function Home() {
const [steps, setSteps] = useState(0)
const health = async () => {
try {
const auth = await RNSamsungHealth.authorize()
let startDate = new Date().setDate(new Date().getDate() - 30) // 30 days back date
let endDate = new Date().getTime() //today's date
let opt = { startDate, endDate }
const steps = await RNSamsungHealth.getDailyStepCount(opt)
setSteps(steps)
} catch (error) {
console.log('error ', error)
}
}
return (
<SafeAreaView>
<Button title="Get Health Data" onPress={health} />
<Text>{steps}</Text>
</SafeAreaView>
)
}
{
"name": "saharatoamazon",
"version": "1.0.0",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"@expo/webpack-config": "^18.0.1",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"expo": "~48.0.18",
"expo-sensors": "^12.3.0",
"expo-splash-screen": "~0.18.2",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.8",
"react-native-paper": "^5.9.1",
"react-native-safe-area-context": "4.5.0",
"react-native-samsung-health": "github:cellihealth/react-native-samsung-health",
"react-native-screens": "~3.20.0",
"react-native-web": "~0.18.10",
"react-navigation": "^4.4.4",
"rn-samsung-health": "^0.1.7"
},
"devDependencies": {
"@babel/core": "^7.20.0"
},
"private": true
}
The code above results in
LOG error [TypeError: Cannot read property 'getConstants' of null]