We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running React Native 0.59.9 and rn-apple-healthkit v0.8.
Completed the following steps:
Still I'm always running into _rnAppleHealthKit.default.initHealthKit is not a function.
_rnAppleHealthKit.default.initHealthKit is not a function
Is there a way to resolve this problem?
import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native'; import AppleHealthKit from 'rn-apple-healthkit'; const PERMS = AppleHealthKit.Constants.Permissions; export class App extends React.Component { constructor(props) { super(props); this.state = { Weight: false, Height: false, DateOfBirth: false, }; } componentDidMount() { const healthKitOptions = { permissions: { read: [ PERMS.DateOfBirth, PERMS.Weight, ] } }; AppleHealthKit.initHealthKit(healthKitOptions, (err, results) => { if (err) { console.log("error initializing Healthkit: ", err); return; } // Date of Birth Example AppleHealthKit.getDateOfBirth(null, (err, results) => { this.setState({ DateOfBirth: results }) }); // Get Latest Weight AppleHealthKit.getLatestWeight(null, (err, results) => { this.setState({ Weight: results }) }); }); } render() { const { DateOfBirth, Weight } = this.state; return ( <View> <StatusBar barStyle="dark-content" /> <SafeAreaView> <ScrollView contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}> <View style={styles.body}> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>Weight</Text> {(Weight) && <Text style={styles.sectionDescription}> {Weight.value} </Text> } {(!Weight) && <Text style={styles.sectionDescriptionError}> Add your Weight to Health App! </Text> } </View> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>Age</Text> {(DateOfBirth) && <Text style={styles.sectionDescription}> {DateOfBirth.age} </Text> } {(!DateOfBirth) && <Text style={styles.sectionDescriptionError}> Add your Birthday to Health App! </Text> } </View> </View> </ScrollView> </SafeAreaView> </View> ); } } const styles = StyleSheet.create({ scrollView: { backgroundColor: '#FFF', }, body: { backgroundColor: '#FFF', }, sectionContainer: { marginTop: 32, paddingHorizontal: 24, }, sectionTitle: { fontSize: 24, fontWeight: '600', color: '#000', }, sectionDescription: { marginTop: 8, fontSize: 18, fontWeight: '400', color: '#555', }, sectionDescriptionError: { marginTop: 8, fontSize: 18, fontWeight: '400', color: '#A00000' }, }); export default App;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Running React Native 0.59.9 and rn-apple-healthkit v0.8.
Completed the following steps:
Still I'm always running into
_rnAppleHealthKit.default.initHealthKit is not a function
.Is there a way to resolve this problem?
The text was updated successfully, but these errors were encountered: