The QR Code Widget allows you to promote app-specific features, and discounts, followed by a QR code that can be scanned to open your app install page on mobile devices.
QR widgets are modals/popups that show up when someone lands on your desktop website, prompting them to get your app.
Here's an example:
ML QR Widget features:
QR Widget can be used importing the JS code via CDN or as a module using NPM
In order to install the QR Code Widget you will want to add the following piece of code into your website, before closing <body></body>
tags:
<script type="module" src="https://cdn.jsdelivr.net/npm/@mobiloud/ml-qr-widget@latest/dist/ml-qr-widget.min.js"></script>
<script>
function addQrWidget() {
new QrWidget().init();
}
window.addEventListener('load', addQrWidget);
</script>
npm i @mobiloud/ml-qr-widget
To learn options available within qrOptions param, reference this: QuickChart's QR Library,
const options = {
fontFamily: `"Source Sans Pro", "Arial", sans-serif`, // (string) Font family for widgets texts, defaults to system safe fonts
textColor: '#222', // (string) Widget texts color (any color property value)
textHeading: 'Get 10% OFF using MobiLoud app', // (string) Heading Text
textDescription: 'Scan our QR to download the app on your device and unlock the discount', // (string) Description text
widgetsColor: '#fff', // (string) Widget BG color
backDrop: true,// (boolean) if true, adds a backdop in front of the page
backDropZIndex: 888888, // (number) z-index of the backdrop, should be lower than widgets z-index
qrOptions: { // Params for the QR Generation, uses params from this docs: https://quickchart.io/documentation/qr-codes/
text: "https://redirect.mobiloud.com/?ios=https://itunes.apple.com/",
size: 150,
margin: 0
},
position: 'center', // (string) Position of the widgets, default 'center'. 'center' | 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right'
animation: 'fadeIn', // (string) Widget animation, default 'fadeIn'. 'fadeIn' | 'scaleUp' | 'slideBottom' | 'slideTop' | 'slideLeft' | 'slideRight' | null,
display: 'onLoad', // (string) Display options, default 'onLoad'. 'onLoad' | 'onScrollDown' | 'onScrollUp'
radius: '10px', // (string) Widget radius with CSS units
delay: 0, // (number) defines how much time to wait until the element shows up
shadow: true, // (boolean) If true applies soft shadow, true | false
useSession: false, // (boolean) If true, after widgets is closed, it creates a session registry to hide widgets on page reloads until the end of user's session
zindex: 999999, // (number) Widget z-index
maxWidth: "400px", // (string) Max Width of the widgets with CSS units
sessionExpire: 1440 // (number) time for banner to show again in minutes starting from the time the banner is shown, defualt: 1440 (1 day)
};
const qrWidget = new QrWidget(options);
deviceData.os // returns current os "android" | "ios" | "windows" | "desktop"
deviceData.isCanvas // returns true or false
deviceData.isMobile // returns true or false
This are useful ways to implement the widget. We always recommend using an Event Listener to trigger the code when the document is loaded window.addEventListener('load', fnName)
function addQrWidget() {
if(deviceData.isMobile || deviceData.isCanvas ){
return
}
new QrWidget(options).init();
}
window.addEventListener('load', addQrWidget);
const options = {
// Set params here
}
// Insert widgets only in our Canvas platform
if(deviceData.isCanvas) {
const qrWidget = new QrWidget(options);
}
// Apply specific configs based on OS
if(deviceData.os === "android" || deviceData.os === "windows") {
const qrWidget = new QrWidget(options1); // different options sets can be passed for different platforms
}
if(deviceData.os === "desktop" || deviceData.os === "ios") {
const qrWidget = new QrWidget(options2);
}
// Insert widgets only in Mobile userAgent
if(deviceData.isMobile) {
const qrWidget = new QrWidget(options3);
}
When 'useSession' parameter is set to true, the banners appears once until the banner is closed, after closed, the banner won't appear until the next day (default) or until the time configured in the 'sessionExpire' parameter, this parameter should have the time in minutes.
1. If user closes the modal, it creates a LocalStorage key called "widgetClosed" with a date value (for example if we set up the sessionExpire value to 1440 (minutes), it would hide until tomorrow)
2. On widget init(), the library checks if the param exists and if the date is bigger than current date
3. If the expiration date already passed, the key is removed from storage and widget is shown again
We provide a custom redirect URL that sends users to the correct app store using a single link.
To use it, simply format the URL like this:
https://redirect.mobiloud.com/?ios=IOS_URL&android=ANDROID_URL
ios
: URL for iOS devices (e.g., App Store link)android
: URL for Android devices (e.g., Google Play link)redirect
: this performs a redirect to a new URL for every platformbuttonColor
: this accepts an hex value (without the '#')when the user open the redirect link on their phone, it will take them to the correct store like so:
These parameters are used for automatically redirecting users to the correct store depending on their device.
https://redirect.mobiloud.com/?android=https://linkToPlaystore.com&ios=https://linkToAppStore.com
When a redirect to a new page is needed for every platform, the ?redirect
parameter can be used along with ?buttonColor.
https://redirect.mobiloud.com/?redirect=https://shorturl.at/OWKx&buttonColor=00376e