Skip to content
New issue

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

_reactNativeAppleHealthkit2.default.isAvailable is not a function #24

Open
svschannak opened this issue Mar 10, 2017 · 6 comments
Open

Comments

@svschannak
Copy link

Hello everybody,

this is my current Code:

import React, { Component } from "react";
import { Image, View } from 'react-native';
import { Container, Icon, DeckSwiper, Card, CardItem, Left, Right, Body, Thumbnail, Text } from 'native-base';
import AppleHealthKit from 'react-native-apple-healthkit';

const HKPERMS = AppleHealthKit.Constants.Permissions;
const HKOPTIONS = {
    permissions: {
        read:  [
            HKPERMS.StepCount,
            HKPERMS.DistanceWalkingRunning,
            HKPERMS.FlightsClimbed,
            HKPERMS.Height,
            HKPERMS.DateOfBirth,
            HKPERMS.BiologicalSex,
            HKPERMS.SleepAnalysis,
        ],
        write: [
            HKPERMS.StepCount
        ],
    }
};

class Health extends Component{
    constructor(props){
        super(props);

    }

    componentDidMount(){

        AppleHealthKit.isAvailable((err, res) => {
            if(err) {
                console.log("error initializing healthkit: ", err);
                return;
            }
            // healthkit initialized...
        });
    }

    render(){


        return(
            <Text>tbd</Text>
        )
    }
}

export default Health;

The Moment the function isAvailable is called i get the following error:

Unhandled JS Exception: _reactNativeAppleHealthkit2.default.isAvailable is not a function
reactConsoleErrorHandler @ ExceptionsManager.js:71
console.error @ YellowBox.js:62
logIfNoNativeHook @ RCTLog.js:38
__callFunction @ MessageQueue.js:242
(anonymous) @ MessageQueue.js:108
guard @ MessageQueue.js:46
callFunctionReturnFlushedQueue @ MessageQueue.js:107
(anonymous) @ debuggerWorker.js:71

I am using the current version from npm.

Can you please help me in finding a way to start to fix this problem? I did every step in the README. Is it possible that i missed something while configuring the XCode-Project?

@MaxMillington
Copy link
Collaborator

@svschannak Which version of React Native are you using?

@amolduse
Copy link

I am too getting the same error. I have these versions - react-native-cli: 2.0.1
react-native: 0.42.2. Which version is supported?

@janstuemmel
Copy link

janstuemmel commented Mar 22, 2017

i think the latest supported version via npm is 0.39.2
submit this version in your package json and do a react-native upgrade

@MaxMillington
Copy link
Collaborator

Yes, @amsds we are waiting on @GregWilson to publish the latest version to npm which will support the breaking changes introduced by react native 0.40. In the mean time, you could fork the repo and then instead of installing from the npm registry just npm install from your own repo.

@amolduse
Copy link

Great. Thanks for quick reply

@seanadkinson
Copy link

@MaxMillington @amsds FYI I've branched and published some fixes at https://github.com/ProvataHealth/react-native-apple-healthkit

yarn add react-native-apple-healthkit-rn0.40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants