scanBarcode

This method will open a full-screen QR code reader in an application

AppMobi.device.scanBarcode();

Description:

This function will open a full-scren QR code reader in an application. Once it successfully reads a QR code, or the reader is cancelled, the appMobi.device.barcode.scan event is called.

Platforms:

Events:

  • appMobi.device.barcode.scan: The appMobi.device.barcode.scan event is called once the QR code reader successfully reads a code or once it is cancelled.

    Example:

    
    document.addEventListener("appMobi.device.barcode.scan",function(evt){
    	AppMobi.notification.beep(1);
    	if (evt.success == true) {
    		//successful scan
    		console.log(evt.codedata);
    
    		if (evt.codedata == "http://www.sampleurl.com/fake.html")
    		{
    			//in the XDK
    		}
    		else
    		{
    			alert(evt.codedata);
    		}
    	}else {
    		//failed scan
    		console.log("failed scan");
    	}
    },false);
    AppMobi.device.scanBarcode();
    			

    Version:

    This method is available in appMobi Version 3.4.0