Newer Version Available

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

Considerations and Limitations

Keep the following in mind when developing features that use the BarcodeScanner API.

Device Limitations

  • BarcodeScanner requires the use of the mobile device camera. The user must grant your app access to the camera. 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 Contacts app 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 Contacts app and needs to change their permissions to allow access, they can do so in their device’s settings.

  • BarcodeScanner doesn’t implement scanning itself. Instead, it makes available the scanning feature of the underlying platform (Android or iOS). While the features provided by BarcodeScanner are the same across both platforms, it is subject to some platform-specific quirks and minor differences.
    • If you can’t get a clear picture of the barcode, it can’t be recognized. The quality of the device camera affects barcode recognition. A damaged or low-quality camera lens or focusing system, poor lighting, motion, and other factors can make it difficult or impossible to get a clear picture of a barcode.
    • The quality of the barcode affects barcode recognition. Specifically, damaged or obscured barcodes are hard to recognize successfully.
  • If you’re having trouble getting BarcodeScanner to recognize a barcode, try the following:
    • First, verify that the barcode type is one of the supported barcode symbologies. There are other barcode types that aren’t supported.
    • Second, verify that you’ve configured BarcodeScanner to recognize the expected symbology. See BarcodeScannerOptions in BarcodeScanner Data Types for configuration details.
    • Finally, check whether another app on the same device is able to recognize the barcode. If the standard camera app on the device can’t recognize the barcode, neither can BarcodeScanner.

Development Considerations

  • BarcodeScanner requires access to camera hardware. To test scanning during development, use actual, physical devices.
    • The Android emulator can simulate camera hardware by using a webcam on your development system. To do so, edit the camera configuration for your Android Virtual Device, in the advanced settings panel. However, the camera built into most laptops is much lower quality than what’s found on modern mobile phones. A low-quality camera limits the usefulness of testing barcode recognition.
    • The iOS simulator doesn’t provide access to simulated camera hardware at all.

You can certainly develop the user experience for your component on a desktop or laptop development system. But be sure to test scanning functionality on the physical devices on which you plan to deploy your Lightning app.

BarcodeScanner Considerations

Be aware of the following considerations when using BarcodeScanner in your Lightning app.

  • BarcodeScanner is built on top of mobile operating system features. BarcodeScanner’s scanning 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 BarcodeScanner can change without notice.
  • BarcodeScanner provides haptic feedback (a short vibration) after a successful scan on iOS devices. There’s no haptic feedback on Android devices.