#StackBounty: #javascript #android #react-native #pedometer TypeError: undefined is not an object (evaluating 'BMDPedometer.isStepC…

Bounty: 100

I’m new to React-Native and building my first application. I am trying to use this library to build a simple Step Counting App. I did the npm install and also the react-natvie link. I am trying to copy the same way that the owner of the library mentioned on the page.

But still I am getting the following error:

TypeError: undefined is not an object (evaluating 
'BMDPedometer.isStepCountingAvailable')
: This error is located at:
in StepsCounter (at App.js:26)
in App (at renderApplication.js:32)
in RCTView (at View.js:43)
in RCTView (at View.js:43)
in AppContainer (at renderApplication.js:31)
TypeError: undefined is not an object (evaluating'BMDPedometer.isStepCountingAvailable')

Here is my StepsCounter.android.js

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import Pedometer from '@asserdata/react-native-universal-pedometer';

export default class StepsCounter extends Component{

constructor(){
    Pedometer.isStepCountingAvailable((error,isAvailable)=>{
if(error) throw error;
        console.log("Working");
    })
}

render()
{
    return(
    <View>
        <Text> Brooooo</Text>
    </View>
    );
}
    }

And here is my App.js

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,AppRegistry} from 'react-native';
import ReactNative from 'react-native';
import Pedometer from '@asserdata/react-native-universal-pedometer';
import StepsCounter from './components/stepscounter';

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,n' +
'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
render() {
return (
  <StepsCounter/>
);
}
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

// ReactNative.AppRegistry.registerComponent('StepsCounter',()=> App);


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.