tjwoon / csZBar

Cordova plugin to integrate with the ZBar barcode scanning library.
Other
143 stars 180 forks source link

zBar not showing on iOS 11 even with #122 or #120 patch #129

Closed matthieu-brillaxis closed 6 years ago

matthieu-brillaxis commented 6 years ago

Hi,

I try to use zbar on iOS 11, but when I launch my function to scan barcode, it did not show the camera. And if I click again on the button to start a scan, it shows an alert with "A scan is already in progress". This happen only on my ipad mini with iOS 11.2.1, I tried on Iphone 6 with iOS 10.3.3 and it display the camera.

On my iPad with iOS 11, i tried this two solutions #122 and #120 , but I get the same error. It works on iPhone and Android with the plugin or with #120 or #122 patch.

I get the following error on xCode 9 console :

WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSRangeException>

How can I make it work on iOS 11 ? I really need your help, I think @phongphan can help me.

Cordova version : 8.0.0 Platforms :

Devices :

My code :

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src * gap: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Test barcode</h1>
            <button onclick="testFunc()">Scan</button>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script>
            function testFunc() {
                var params = {
                    text_title: "OPTIONAL Title Text - default = 'Scan QR Code'", // Android only
                    text_instructions: "OPTIONAL Instruction Text - default = 'Please point your camera at the QR code.'", // Android only
                    camera: "back", // defaults to "back"
                    flash:"auto", // defaults to "auto". See Quirks
                    drawSight: true //defaults to true, create a red sight/line in the center of the scanner view.
                }
                cloudSky.zBar.scan(params, onSuccess, onFailure);
            }

            function onSuccess(s) {
                alert(s);
            }

            function onFailure(s) {
                alert(s);
            }
        </script>
    </body>
</html>
phongphan commented 6 years ago

Hi,

I have tested it on the emulator (I don't own an iPad). And it seems to work. Could you give more details about the error?

I believe the xcode output could give more details Eg. [__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 1]

matthieu-brillaxis commented 6 years ago

Thanks for your answer,

2018-01-12 09:19:31.736215+0100 HelloCordova[852:12871] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSRangeException> *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]

I can upload my project on github if you want.

phongphan commented 6 years ago

Not sure if this line is executed https://github.com/phongphan/csZBar/blob/b573955650b2fedb022d8192ef6796aeb1fb21e7/ios/CsZBar.m#L78

Since it might not happened after we patched it and build the app with IOS 11 SDK. You could try remove this block entirely (#ifdef to #endif). And make sure that the csZBar.m in plugins and in platforms/ios are in sync.

The project would help. If it's another iPad specific issues. I'll update the patch :)

matthieu-brillaxis commented 6 years ago

I just copy and paste your CsZBar.m into my project to replace mine :

https://github.com/phongphan/csZBar/blob/b573955650b2fedb022d8192ef6796aeb1fb21e7/ios/CsZBar.m#L78

It is working on my Ipad IOS 11.

Thank you for your help, you are awesome ! šŸ‘ šŸ˜„

I close it.