Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27804] Front camera and cancel button option missing while open camera using ti.barcode module

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionDuplicate
Resolution Date2020-03-16T11:33:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsiphone
Reportershishir.roy
AssigneeEwan Harris
Created2020-02-18T08:24:56.000+0000
Updated2020-04-09T09:43:45.000+0000

Description

The front camera and cancel button missing on open barcode camera.
Titanium SDK:8.2.1.GA
 <module platform="iphone" version="2.0.4">ti.barcode</module>
iOS Device: iPad Mini
version: 13.3 
Please suggest how to fix this issue Attached screenshot

Attachments

FileDateSize
IMG_0976.PNG2020-02-18T08:24:39.000+00005181818

Comments

  1. Ewan Harris 2020-02-18

    [~shishir.roy] please provide sample code for how you're using ti.barcode so we can troubleshoot
  2. shishir.roy 2020-02-18

    I have attached code snippet below: Note: The same code is working expected behavior in iOS 11.
       function ShowTiBarcodeScanner(controltoUse, lFrom, GetScannedCode, OnCancel)
       {
           var sFailPoint = "top";
           var bCalled = false;
           var bShowAlertAfterSuccessfulScan = false;
           var bScanSuccess = false;
       	try
       	{
       		if(!Ti.Media.hasCameraPermissions())
       		{
       			alert(L('msg_no_camera_permission'));
       			return false;
       		}
       		var Barcode = require('ti.barcode');
       		Barcode.allowRotation = true;
       		Barcode.displayedMessage = ' ';
       		Barcode.allowMenu = true;
       		Barcode.allowInstructions = false;
       		Barcode.useLED = true;
       		
       	
       		var overlay = Ti.UI.createView({
       		    backgroundColor: 'transparent',
       		    top: 0, right: 0, bottom: 0, left: 0
       		});
       		var switchButton = Ti.UI.createButton({
       		    title: Barcode.useFrontCamera ? L('title_backcamera','Back Camera') : L('title_frontcamera','Front Camera'),
       		    textAlign: 'center',
       		    color: '#000', backgroundColor: '#fff', style: 0,
       		    font: { fontWeight: 'bold', fontSize: 16 },
       		    borderColor: '#000', borderRadius: 10, borderWidth: 1,
       		    opacity: 0.5,
       		    width: 220, height: 30,
       		    bottom: 10, left:20
       		});
       		switchButton.addEventListener('click', function () {
       		    Barcode.useFrontCamera = !Barcode.useFrontCamera;
       		    switchButton.title = Barcode.useFrontCamera ? L('title_backcamera','Back Camera') : L('title_frontcamera','Front Camera');
       		});
       		overlay.add(switchButton);
       		var cancelButton = Ti.UI.createButton({
       		    title: L('Cancel_title','Cancel'), textAlign: 'center',
       		    color: '#000', backgroundColor: '#fff', style: 0,
       		    font: { fontWeight: 'bold', fontSize: 16 },
       		    borderColor: '#000', borderRadius: 10, borderWidth: 1,
       		    opacity: 0.5,
       		    width: 220, height: 30,
       		    bottom: 10, right:20
       		});
       		cancelButton.addEventListener('click', function () {
       		    Barcode.cancel();
       		});
       		overlay.add(cancelButton);
       		
       		/**
       		 * Create a button that will trigger the barcode scanner.
       		 */
       		var scanCode = Ti.UI.createButton({
       		    title: 'Scan Code',
       		    width: 150,
       		    height: 60,
       		    top: 20
       		});
       		
               var ScanSuccess = function(e) {
       	            bScanSuccess = false;
                       bCalled = true;
                       bScanSuccess = true;
                      cancelButton.fireEvent("click");
       			};
       
       		Barcode.addEventListener('error', function (e) {
       		   alert(L('msg_fail_to_scan') + ":" +  e.message);
       		});
              Barcode.addEventListener('cancel', function (e) {
                   try
                   {
       	            Ti.API.info('Cancel received');
       	            if (bScanSuccess == false)
       	            {
       	        		OnCancel();            	
       	            }
                   }
                   catch(ex)
                   {
                       
                   }
               });
       		Barcode.addEventListener('success', function (e) {
       			ScanSuccess({barcode:e.result});
       		    Ti.API.info('Success called with barcode: ' + e.result);
       		});
       		
       		setTimeout(function()
       			{// Note: while the simulator will NOT show a camera stream in the simulator, you may still call "Barcode.capture"
       		    // to test your barcode scanning overlay.
       		    Barcode.capture({
       		        animate: false,
       		        overlay: overlay,
       		        showCancel: false,
       		        showRectangle: true,
       		        keepOpen: true,
       		        acceptedFormats: [
       		            Barcode.FORMAT_QR_CODE, Barcode.FORMAT_CODE_39
       		        ]
       		    });},5);
       		
       	}
       	catch(ex)
       	{
       		Ti.API.info("error occured in ShowTiBarcodeScanner:" + ex.message);
       	}
       }
       
  3. shishir.roy 2020-03-11

    Any update on this issue
  4. Ewan Harris 2020-03-12

    [~shishir.roy] I believe the issue you're seeing is caused by MOD-2584, on iOS 13 the barcode window will be opened as a modal which is causing the UI content to be shifted slightly. This isn't seen iOS versions lower than 13 as they do not support modal windows. As a workaround while we review that PR, when creating the two buttons, change the bottom: 10 to a larger value.
  5. Ewan Harris 2020-03-16

    I'm going to close this as a duplicate of MOD-2584
  6. shishir.roy 2020-04-09

    Hi Ewan, I have checked with ti.barcode-iphone-5.0.0.zip in my application which is provided on the below link. https://github.com/appcelerator-modules/ti.barcode/pull/121 But still, the issue exists. So I wanted to know the compatibility of this module. Currently, I have checked on below environment: iOS: 13 Titanium SDK: 8.2.1.GA node js: 8.11.2 Xcode: 11 please let me know if this issue is fixed with above environment. Or I have to must need the below environment: SDK: 9.0.0.GA Appc CLI: 8.0.0 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202003181504 Xcode: 11.4

JSON Source