PDF417 / pdf417-phonegap

PDF417 and QR code scanning plugins for PhoneGap/Cordova framework
47 stars 21 forks source link

pdf417-phonegap not working when started from inappbrowser-like cordova plugins #21

Closed maurodsantos closed 8 years ago

maurodsantos commented 8 years ago

Hi guys, I'm trying to use your plugin in a web-app which is loaded in a cordova app using the inappbrowser or themeablebrowser plugins. when I started the pdf417 view by pushing a button from the inappbrowser context I have the following mistake: Warning: Attempt to present <CameraViewController: 0x13f309220> on <MainViewController: 0x13dd26620> whose view is not in the window hierarchy!

And I cannot see the camera. I've tried a fix, to get the cameraviewcontroller to the parent view (on the native code), which shows the camera, but them when I get a results from your plugin, and get back to the inappbrowser view it comes blank.

this happens for the iPad mini 2 in the IOS 9.0.

Did you have an issue related with this one? Thank you for your time,

Mauro

Cerovec commented 8 years ago

Hi Mauro,

to understand the first error, you have to know that pdf417 library presents camera view controller using method presentViewController, on top of currently presented view controller. The exact line of code which does that is here: https://github.com/PDF417/pdf417-phonegap/blob/master/Pdf417/src/ios/sources/CDVpdf417.m#L244.

Here pdf417 uses viewController property of the CDVPlugin class. Apparently in your app this returns a viewController whose view is not in the view hierarchy (this can happen, for example, if the view controller is currently being dismissed).

pdf417 SDK cannot do much about that. You can either modify your app so that this property returns a valid view controller, your you can change the plugin so that it work for your use case.

The second error I didn't really understand. Which view controller comes blank, camera, or inappbrowser?

Is it possible you share javascript code u use for invoking the scanner?

Thanks, Jurica.

On Thu, Jan 7, 2016 at 12:33 PM, Mauro notifications@github.com wrote:

Hi guys, I'm trying to use your plugin in a web-app which is loaded in a cordova app using the inappbrowser or themeablebrowser plugins when I started the pdf417 view by pushing a button from the inappbrowser context I have the following mistake: Warning: Attempt to present on whose view is not in the window hierarchy!

And I cannot see the camera I've tried a fix, to get the cameraviewcontroller to the parent view (on the native code), which shows the camera, but them when I get a results from your plugin, and get back to the inappbrowser view it comes blank

this happens for the iPad mini 2 in the IOS 90

Did you have an issue related with this one? Thank you for your time,

Mauro

— Reply to this email directly or view it on GitHub https://github.com/PDF417/pdf417-phonegap/issues/21.

Jurica Cerovec, M.Sc.

mobile: +385 98 993 8076 skype: cerovec

http://photomath.net http://microblink.com

maurodsantos commented 8 years ago

Thanks for your help. I did change that line to [self.getTopPresentedViewController presentViewController:scanningViewController animated:YES completion:nil]; just to complete: [self.getTopPresentedViewController presentViewController :scanningViewController animated:YEScompletion:nil];

-(UIViewController )getTopPresentedViewController { UIViewController presentingViewController = self.viewController; while(presentingViewController.presentedViewController != nil) { presentingViewController = presentingViewController. presentedViewController; } return presentingViewController; } and then I was able to see the camera, when issued from the inappbrowser plugin, but on completion of the camera task, I no longer see the inappbrower screen with my webpage.

For the second problem, I found this is an issue with the inappbrowser plugin, which cannot be used like this with your plugin, as its view is dismissed.

Thanks again for your help.

maurodsantos commented 8 years ago

I made it work by using an iframe directly. Best, Mauro