Comments (4)
The issue is that even though you have the correct permissions in AndroidManifest.xml
for fine location, you are only requesting coarse
permissions here:
RNLocation.requestPermission({
ios: "always",
android: {
detail: "coarse"
}
});
That should be changed to:
RNLocation.requestPermission({
ios: "always",
android: {
detail: "fine"
}
});
from react-native-location.
Can you let me know:
- Which platform are you seeing this behaviour on?
- Is this on a real device or a simulator/emulator?
- What Android permissions do you have in
AndroidManifest.xml
? - What permissions reasons do you have in
Info.plist
? - What configuration options are you passing before subscribing to updates?
from react-native-location.
=> My platform is Android.
=> I am testing it on a real device.
=> My permission in AndroidManifest.xml as shown below:
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
=> These are my code :
componentWillMount() {
RNLocation.configure({
distanceFilter: 0, // Meters
desiredAccuracy: {
ios: "best",
android: "balancedPowerAccuracy"
},
// Android only
androidProvider: "auto",
interval: 5000, // Milliseconds
fastestInterval: 10000, // Milliseconds
maxWaitTime: 5000, // Milliseconds
// iOS Only
activityType: "other",
allowsBackgroundLocationUpdates: false,
headingFilter: 1, // Degrees
headingOrientation: "portrait",
pausesLocationUpdatesAutomatically: false,
showsBackgroundLocationIndicator: false,
})
}
componentDidMount() {
RNLocation.requestPermission({
ios: "always",
android: {
detail: "coarse"
}
}).then(granted => {
if (granted) {
this.locationSubscription = RNLocation.subscribeToLocationUpdates(locations => {
console.log(locations)
/* Example location returned
{
speed: -1,
longitude: -0.1337,
latitude: 51.50998,
accuracy: 5,
heading: -1,
altitude: 0,
altitudeAccuracy: -1
floor: 0
timestamp: 1446007304457.029
}
*/
})
}
})
}
=> The output is like this:
[ { timestamp: 1551433571853,
speedAccuracy: 0,
speed: 0,
courseAccuracy: 0,
course: 0,
altitudeAccuracy: 0,
altitude: 0,
accuracy: 2000,
longitude: 29.00299727646425,
latitude: 41.04504504504504 } ]
=> The devices I used are ;Android 6.0 and Android 7.0 (Real device)
from react-native-location.
Thank you very much for your answers,it worked
from react-native-location.
Related Issues (20)
- subScribeLocationChanges() HOT 3
- 🔥 Method addObserver must be called on the main thread HOT 2
- Terrible accuracy - physial device Android 10, RN 0.6.4 HOT 3
- Is there any good and well-maintained alternative to this package? HOT 1
- Cant stop updates of RNLocation.subscribeToLocationUpdates HOT 2
- Not return heading HOT 2
- background configuration throwing error
- Failed to build android because of java classes HOT 9
- Wanings about some event emitters, about AddListener and removeListeners HOT 1
- subscribeToSignificantLocationUpdates doesn't work to me
- Undefined symbols for architecture arm64 HOT 1
- Requesting "always" permission when user has previously selected "whenInUse" causes request to hang (promise never resolves) (deprecate this library) HOT 2
- Failed to Build HOT 12
- Is this repo dead?
- RNLocation functions issue HOT 5
- nvert
- Error: package android.support.annotation does not exist HOT 2
- Not working when mobile in sleep mode[Android] HOT 1
- Error - Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void
- Fatal Exception: java.lang.NullPointerException
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-location.