smekalka / react-native-universal-pedometer Goto Github PK
View Code? Open in Web Editor NEWReact-native pedometer for IOS and Android
React-native pedometer for IOS and Android
Hello,
I'm pretty new to React Native, I have tried to install react-native-universal-pedometer several times with npm ("npm react-native-universal-pedometer" then "react-native link", and also link Binary With Librairies using "libBMDPedometer.a" in XCode), but I didn't succeed.
When running though iOS simulator, I got this error:
error: bundling failed: ambiguous resolution: module /myreactnativeproject/index.js
tries to require react-native
, but there are several files providing this module. You can delete or fix them:
/myreactnativeproject/node_modules/react-native-universal-pedometer/node_modules/react-native/package.json
/myreactnativeproject/node_modules/react-native/package.json
I have tried to remove the "react-native" dependency from the package.json in the "react-native-universal-dependency" directory, but it throws an error.
Have you got any idea on how to solve this? Thanks!
After installing it with yard add and linking through react-native link. It still works fine on android. If I comment import Pedometer from 'react-native-universal-pedometer', it loads, and if I uncomment it, it throws an error Native module cannot be null. I tried reinstalling it, didn't work.
In BMDPedometerModule.java since you are using startAt as long, which is logic because you are using currentTimeMillis method, also should return a long. The issue is that map.putInt("startDate", (int)this.startAt); simplifies the startAt value, giving a wrong value when the object is returned in javascript.
I used these lines of code in my app for getting Steps.
import Pedometer from 'react-native-universal-pedometer';
Pedometer.isStepCountingAvailable((error, isAvailable) => {
if (isAvailable) {
const startDate = new Date();
startDate.setHours(0, 0, 0, 0);
const endDate = new Date();
Pedometer.queryPedometerDataBetweenDates(
startDate.getTime(),
endDate.getTime(),
pedometerData => {
console.log(pedometerData);
},
);
} else {alert("error")}
});
pedometerData always return
{"distance": 0, "endDate": -62508770, "numberOfSteps": 0, "startDate": 0}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.