I am new on React Native, could you helpe me? I have just installed the react-native-sensors(Yarn add --save react-native-sensors), then I imported on my project(import { Accelerometer } from "react-native-sensors";) but I receive this message "Native Modules for sensors not available. Did react-native link run successfully?"
I runned the command "react-native link react-native-sensors", but the error still persists =(
I am using the "react-native-sensors": "^5.1.5".
and this is my package.json
{
"name": "tcc_mobile",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"lodash": "^4.17.11",
"react": "16.6.1",
"react-native": "0.57.7",
"react-native-gesture-handler": "^1.0.10",
"react-native-sensors": "^5.1.5",
"react-navigation": "^3.0.8",
"rxjs": "^6.3.3"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.5",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}
Thanks ! =)
Check your AVD for sensor capabilities and try to work with real devices. It woks fine for me with the given dependency version:-
"react-native-sensors": "^5.1.8". Here is a little code snippet:-import { accelerometer, gyroscope, setUpdateIntervalForType, SensorTypes } from "react-native-sensors"; accelerometer.subscribe(({ x, y, z, timestamp }) => { console.log(X: ${ x }, Y:${y}, Z:${z}, timestamp: ${timestamp})