Newer Version Available

This content describes an older version of this product. View Latest

Compatibility and Requirements

LocationService is a JavaScript module that provides an API to Lightning web components to make mobile hardware and platform (operating system) features available in JavaScript. LocationService requires access to device hardware and device platform APIs. This access is only available when LocationService runs within a compatible Salesforce mobile app. It does not and cannot function when running in a standard web browser, whether the browser runs on a desktop or mobile device.

LocationService is available in Lightning apps distributed using:

  • Salesforce Mobile app
  • Mobile Publisher for Salesforce App
  • Mobile Publisher for Experience Cloud
  • Field Service Mobile app

LocationService is fully functional when used in a Lightning app or Lightning site run from one of these Salesforce apps on a compatible iOS or Android mobile device. See Requirements for the Salesforce Mobile App, Requirements for Mobile Publisher for Salesforce App, Field Service Mobile App Requirements, or the requirements page for your target mobile app, for specific device and operating system requirements.

LocationService is not fully functional when running on other devices, such as a desktop, or when running in a standard web browser, even on a mobile device. It requires one of the mobile apps listed above. The LocationService API is accessible in Lightning Experience on all devices, so your code won’t fail due to missing functions. However, when your app runs in a browser—desktop or mobile—it can use only LocationService constants and utility functions. Attempting to use location-specific features will fail.

LocationService only provides location data, in the form of geo-coordinates and some metadata. What you do with the location data is up to your component to parse, compare, and place in context—for example, to calculate distance, display on a map, and so on.