Closed pk936 closed 4 years ago
did you find solution for this?
No. At the end I had to remove this package.
I don't get it, it worked for me :
import React from 'react';
import RNAndroidLocationEnabler from 'react-native-android-location-enabler';
const App = () => {
React.useEffect(() => {
RNAndroidLocationEnabler.promptForEnableLocationIfNeeded({interval: 10000, fastInterval: 5000})
.then((data) => {
console.log('data', data)
}).catch((err) => {
console.log('error', err)
});
}, [])
return ()
};
export default App;
{
"name": "EnableLocation",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-android-location-enabler": "^1.2.1"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
Device : Nexus 5X API 29.
I added this line
RNAndroidLocationEnabler.promptForEnableLocationIfNeeded( ... )
on press event and useeffect. Both sides it sayserr [TypeError: null is not an object (evaluating '_reactNativeAndroidLocationEnabler.default.promptForEnableLocationIfNeeded')]