Scan Barcodes Natively on a Mobile Device using LWC
on
Get link
Facebook
X
Pinterest
Email
Other Apps
A Lightning web component can use a mobile device’s camera and mobile OS
platform features to scan a barcode, such as a UPC symbol or QR code. When a
barcode is successfully scanned, the data that was read from the barcode is
returned to the Lightning web component that invoked it.
Scanning is performed locally on the mobile device, and doesn’t need a network
connection. BarcodeScanner does require access to platform-specific APIs that
are available only within compatible Salesforce mobile apps.
Scan Barcode on Mobile
IMPORTANT BarcodeScanner does not and cannot function when running in a web
browser, whether running on a desktop or mobile device.
Salesforce has recently released a new
Barcode API
which supports barcode scanning natively on LWC for mobile devices. As it’s
supported natively, we don’t need to worry about maintaining 3rd party
Javascripts, Locker services, performance issues, etc.
Implementation:
The barcode API allows us to scan the barcodes natively using LWC. The
scanning can be done in two ways
For the demo purpose and understanding how the Barcode API works, we will
focus on Single Scanning only and then this can be extended to
Continuous Scanning on demand basis.
Pre-requisites:
You need to have a salesforce1 mobile app installed in your mobile
You need a login account on Salesforce(Prod/Dev/Sandbox)
Steps:
Create a LWC component
Create a Lightning Tab
Demo
Now let's deep dive into the implementation steps.
Create a LWC component:First
step is to create a LWC component named
barcodeScanner
barcodeScanner.html
<template>
<divclass="slds-card">
<divclass="slds-text-align_center">
<spanclass="slds-text-heading_large">BarcodeScanner: Single Scan</span>
</div>
<!-- After a barcode is successfully scanned, its value is displayed here: -->
Create a Lightning Tab: Now create a
lightning tab in our Salesforce org
Go to set up → Tabs
Click on New and select the barcodeScanner from available options
and provide other details
Click Next and make default on for all profiles.
Click Save
Demo:
Now as we have been through all the coding required for Barcode Scanning, time
to have a look how the scanning works. We have added only two supportive
scanning options in our demo
This blog sharing really out of the box information, this time you came up with different content that's really amazing. Thank you for knowledge sharing blog. Please check if you can come with data visualization in salesforce related content.
I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting. Maybe we can see more on this. 2captcha login
This blog sharing really out of the box information, this time you came up with different content that's really amazing. Thank you for knowledge sharing blog. Please check if you can come with data visualization in salesforce related content.
ReplyDeleteThanks for the feedback.
DeleteI have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting. Maybe we can see more on this. 2captcha login
ReplyDelete