Generate and display a barcode or QR code in your app
PRE-REQUISITES
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:
- When in Fliplet Studio’s Edit screen, open the Developer Options from the right hand menu
- With the Developer Options open, click the Libraries button in the top right corner
- In the search field, type in ‘fliplet-barcode’
- Click it to add it to the list
- Click Save
Fliplet.Barcode.show()
can be used to present a barcode/QR code on the screen based on the text that has been provided (ie, the text that you want to be encoded in the barcode or QR code). By default the text is encoded into a QR code. See here for more options.
The example below transforms ‘https://fliplet.com’ into a barcode.
JavaScript
var options = {
format: 'qr',
color: '#000000',
background: '#ffffff',
title: 'My QR code',
message: 'Scan it with your camera.',
height: 150,
lineWidth: 2 // Only applies to barcodes
};
Fliplet.Barcode.show('https://fliplet.com', options)
.catch(function (error) {
// Encoding failed
console.log(error);
});