Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthieu-brillaxis opened this issue Jan 11, 2018 · 4 comments
Closed

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

matthieu-brillaxis opened this issue Jan 11, 2018 · 4 comments

Comments

@matthieu-brillaxis
Copy link

matthieu-brillaxis commented Jan 11, 2018

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 :

  • iOS : 4.5.4
  • Android : 6.4.0

Devices :

  • iPhone 6 : iOS 10.3.3
  • iPad mini 2 : iOS 11.2.1
  • Samsung galaxy S6 : Android 7.0

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
Copy link

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
Copy link
Author

matthieu-brillaxis commented Jan 12, 2018

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
Copy link

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
Copy link
Author

matthieu-brillaxis commented Jan 16, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants