Develop Secure Code
LocationService Data Types
getLocationService()
isAvailable()
getCurrentPosition(options)
startWatchingPosition(options, callback)
stopWatchingPosition(watchId)
isAvailable()Determines whether location service functionality is available.
1import { getLocationService } from 'lightning/mobileCapabilities';
2isAvailable(): BooleanNone.
Returns true when used on a supported device, and false otherwise.
Use this function to disable or hide location-based features on platforms where location services aren’t supported. For example:
1handleFindMeClick() {
2 const myLocationService = getLocationService();
3 if (myLocationService.isAvailable()) {
4 // Perform location-based requests
5 }
6 else {
7 // LocationService isn’t available
8 // Not running on hardware with GPS, or not inside mobile app
9 // Handle with message, error, beep, and so on
10 }
11}See Also