barcode-scanner icon indicating copy to clipboard operation
barcode-scanner copied to clipboard

TO JS undefined

Open RyanYangGit opened this issue 2 years ago • 4 comments

When i run on ionic6, it doesn't work. The xcode output shows "TO JS undefined", no matter use BarcodeScanner.hideBackground() or BarcodeScanner.startScan(). Is anyone also got this error?

RyanYangGit avatar Jun 15 '22 15:06 RyanYangGit

I have no issues in with my ionic 6 test setup, the plugin works as expected in my case so it might be an issues with your setup and not the plugin itself.

Can you share a repo where I can reproduce your issue?

thegnuu avatar Jun 15 '22 15:06 thegnuu

I'm getting this too. When looking at Xcode I can see a warning:

discoverCaptureDevices()' is deprecated: New Xcode? Check if AVCaptureDevice.DeviceType has new types and add them accordingly.

kieranbarlow avatar Jul 11 '22 10:07 kieranbarlow

Same here.

@ionic/vue v6.0.0 Capacitor v4.0.1 barcode-scanner v3.0.0

Xcode log

sjonkeesse avatar Aug 16 '22 13:08 sjonkeesse

For me this was the issue. In @capacitor-community/barcode-scanner/ios/Plugin/Plugin.swift the UIApplication.shared.statusBarOrientation was not just deprecated, but is obsolete. This line:

self.videoPreviewLayer?.connection?.videoOrientation = interfaceOrientationToVideoOrientation(UIApplication.shared.statusBarOrientation)

should be replaced to something like this

if let interfaceOrientation = UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.interfaceOrientation {
    self.videoPreviewLayer?.connection?.videoOrientation = interfaceOrientationToVideoOrientation(interfaceOrientation)
}

The TO JS undefined log remains, but the barcode scanner seems to work.

sjonkeesse avatar Aug 16 '22 14:08 sjonkeesse

I have gotten the same problem 20230307162808

BREEZE1987 avatar Mar 07 '23 08:03 BREEZE1987

Me too Screenshot 2023-03-16 at 15 57 53

DidoMarchet avatar Mar 16 '23 14:03 DidoMarchet

Fixed in the current pre-release v5

thegnuu avatar May 08 '23 14:05 thegnuu