Integrate Native Device Capabilities with Mobile Skills

Use the mobile-platform-native-capabilities-integrate skill to build Lightning web components (LWCs) that use native mobile device features, such as the barcode scanner, biometrics, location, and NFC, through the lightning/mobileCapabilities module. Describe the capability you want in natural language, and the skill wires the service into your LWC with the correct availability checks, error handling, and current APIs.

The lightning/mobileCapabilities module exposes factory functions that return service objects for native device features. Each service extends a common base capability that includes an isAvailable() method, so your component can degrade gracefully on surfaces where the capability isn’t present, such as desktop and mobile web. Instead of requiring you to memorize each service’s API, the skill routes your AI agent through three steps. The agent chooses the right capability, loads the authoritative type definitions, and wires the service into your LWC with the correct availability gating, error handling, and current API choices.

In Agentforce Vibes, this skill is available out of the box. In other AI coding environments, install it by running npx skills add https://github.com/forcedotcom/sf-skills --skill mobile-platform-native-capabilities-integrate. For installation details and environment requirements, see Install Mobile Skills.

Note

Use this skill when you want an LWC that:

  • Scans a barcode or a paper document with the camera
  • Reads location or triggers logic at a geofence boundary
  • Prompts for biometrics, such as Face ID or a fingerprint
  • Reads or writes the device calendar or contacts
  • Taps an NFC tag
  • Takes an Apple Pay or Google Pay payment
  • Prompts for an in-app review
  • Scans a physical space with augmented reality

Available Native Capabilities 

The skill supports the native device capabilities exposed by the lightning/mobileCapabilities module.

CapabilityUse Case
App ReviewPrompt the user for a native in-app review.
AR Space CaptureCapture a 3D scan of a physical space using augmented reality.
Barcode ScannerRead QR, UPC, EAN, Code 128, and other barcode types from the camera.
BiometricsAuthenticate with Face ID or a fingerprint.
CalendarRead or create events on the device calendar.
ContactsRead or create entries in the device address book.
Document ScannerScan paper documents using the camera with edge detection.
GeofencingTrigger logic when the device crosses a geographic boundary.
LocationRead GPS coordinates and watch for updates.
NFCRead or write NFC tags.
PaymentsTake an Apple Pay or Google Pay payment.

What the Skill Does 

When you describe the device feature that you want, the skill:

  • Maps your request to the correct capability. If your feature spans multiple capabilities, such as scanning a barcode and saving it to a contact, the skill plans for each capability separately because there’s one factory function per capability.
  • Loads the authoritative TypeScript definitions for the capability, including the factory function, service interface, options types, result types, and error types, rather than inferring the API from memory. The services evolve, and some methods are deprecated in favor of newer alternatives.
  • Wires the service into your LWC with an import from lightning/mobileCapabilities, an isAvailable() gate before every call, the current, non-deprecated entry point, and typed error handling for each failure code.

Availability and Error Handling 

Native capabilities are available only when the LWC runs inside a supported Salesforce mobile app, such as the Salesforce mobile app or the Field Service mobile app. When the same component renders on desktop or mobile web, the factory function still returns an object, but isAvailable() returns false. The skill gates every capability call behind an isAvailable() check so that your component degrades gracefully on unsupported surfaces.

Each service defines its own failure-code enum, such as BarcodeScannerFailureCode or LocationServiceFailureCode. The skill maps each rejection path to a user-actionable outcome. For example:

  • A denied permission prompts the user to grant access.
  • A disabled permission directs the user to the operating system settings.
  • A service that isn’t enabled surfaces a developer-visible error rather than a user-facing message.

Example Prompts 

  • “Add a barcode scanner to this LWC and write the scanned value into the field.”
  • “Take an Apple Pay payment for the order total in this component.”
  • “Prompt for Face ID before showing the record details in this LWC.”
  • “Read the device location and show the nearest accounts.”

After you describe the capability, the skill identifies the matching service, loads its reference, and wires it into your component with the correct availability checks and error handling.

For LWCs that ship in offline mode, use the mobile-platform-offline-validate skill to review your component for offline-priming compatibility.