For the following code examples to work, you will need to add the fliplet-barcode library to your app. To add it follow these steps:

  1. When in Fliplet Studio’s Edit screen, open the Developer Options from the right hand menu
  2. With the Developer Options open, click the Libraries button in the top right corner
  3. In the search field, type in ‘fliplet-barcode’
  4. Click it to add it to the list
  5. Click Save

Barcodes or QR codes are visual representations of a long string of letters and numbers. There are predefined formats for this which Fliplet can detect automatically.

The following code will open Fliplet’s barcode scanner (and start using the device’s camera – the user’s permission may be required to use the camera).

It repeatedly scans for the barcode. When it detects a barcode or QR code then a ‘result’ will be generated. The result contains three pieces of information:

  • result.text – will give you the text encoded in the barcode
  • result.format – will tell you what format the barcode was (eg, ‘qr’ or ‘barcode’)
  • result.cancelled – is typically false but will be set to true when a user cancels the scan
  .then(function (result) {
    // Add custom code here to use the result from the scan
    // result.text - the decoded text from the barcode or QR code
    // result.format - tells you what format the code is
    // result.cancelled - true if user cancels the scan
  .catch(function (error) {
    // Scan failed
Was this article helpful?