Newer Version Available
Considerations and Limitations
Device Limitations
LocationService doesn’t implement location calculation itself. Instead, it makes available certain location features of the underlying platform (Android or iOS) and hardware (phone or other mobile device). While the features provided by LocationService are the same across both platforms, they are subject to some platform-specific quirks and minor differences.
- LocationService requires the use of the mobile device location detection hardware. The user must grant your app access to the device’s location. The exact user experience is governed by the platform. The request happens automatically on first use, and is managed by the device itself, but you should plan for it when designing the user experience of your app.
-
In Android 11 or later, if the user taps “Deny” for permission to access the mobile device location more than once during the app’s lifetime of installation on a device, the user won’t see the system permissions dialog again. Tapping Deny multiple times implicitly chooses the “don’t ask again” option.
In previous versions of Android, users would see the system permissions dialog each time the app requested permission unless the user had previously selected “don’t ask again”. This change in Android 11 discourages repeated requests for permissions that users have chosen to deny.
If the user has denied permission to access the mobile device location and needs to change their permissions to allow access, they can do so in their device’s settings.
- Location tracking is subject to significant privacy, processing, and power use restrictions, imposed by the underlying platform (Android or iOS). See important details in the LocationService API reference documentation.
- Many factors affect the accuracy of location detection, the speed of determining the current location, and how much impact location tracking has on battery life.
- Mobile devices vary in the quality of the location detection they provide.
- If a mobile device can’t determine its location, neither can LocationService. The quality of the device’s positioning hardware, tall or dense buildings, indoor use, and other external factors can reduce the accuracy of location determination.
- Location tracking on high accuracy can significantly increase power use, which affects how quickly a mobile device drains its battery.
- First, verify that the device is able to determine its location. If the standard Maps app can’t get an accurate location, neither can LocationService.
- Next, verify that the user has granted location access to the mobile app where your component is running.
- Finally, double-check the configuration of LocationService in your code. In particular, verify that you’ve set the accuracy level as needed for your component’s features.
Development Considerations
LocationService requires access to positioning hardware, such as GPS, Wi-Fi, cellular, and other location-detection hardware of your mobile device. To test location services during development, use actual, physical devices when possible.
- The Android emulator and iOS simulator can each be configured to provide simulated location details.
- Neither virtual device accurately simulates location detection in the real world, especially for environments where location detection is challenging.
You can certainly develop the user experience for your component on a desktop or laptop development system. But be sure to test location-based functionality on the physical devices on which you plan to deploy your Lightning app.
LocationService Considerations
Be aware of the following considerations when using LocationService in your Lightning app.
- LocationService is built on top of mobile operating system and device features. LocationService’s location capabilities therefore depend on Android or iOS features, which are subject to change beyond our control. When mobile operating system features change, the behavior of LocationService can change without notice.
- LocationService doesn’t provide map data. To display the current location on a map, you need to add extra functionality, for example, to retrieve map tile graphics.
- LocationService detects a device’s current location only. While you can receive updates when the current location changes, updates provide only the new location. If needed, perform distance, proximity, or geofencing calculations yourself, in your own JavaScript.