Github user jcesarmobile commented on the pull request:

    
https://github.com/apache/cordova-plugin-dialogs/pull/54#issuecomment-183218924
  
    It's supposed to be recursive. If count > 1 it just stores it on the array 
(line 100), then, once it's presented (line 230), removes the presented 
alertController from the array (line 231), and if the array contains any other 
alertController on the array (line 232), it calls presentAlertcontroller again 
(line 233).
    
    I've tested and the problem is on the barcode scanner plugin, it returns 
the success or error callbacks right after calling 
dismissViewControllerAnimated, and dismissViewControllerAnimated takes a while, 
so the alert tries to present the dialog on the CDVbcsViewController that is 
being dismissed, so you get this error:
    Warning: Attempt to present <UIAlertController: 0x14f913bd0> on 
<CDVbcsViewController: 0x14f90c830> whose view is not in the window hierarchy!
    
    The solution should be not to return the callbacks until the 
CDVbcsViewController is dismissed. Than can be done with a block like this:
    
    `- (void)barcodeScanDone:(void (^)(void))callbackBlock {
        self.capturing = NO;
        [self.captureSession stopRunning];
        [self.parentViewController dismissViewControllerAnimated:YES 
completion:callbackBlock];
        
        // viewcontroller holding onto a reference to us, release them so they
        // will release us
        self.viewController = nil;
    }`
    
    and every call to barcodeScanDone should pass the block as parameter
    
    example:
    
    `[self barcodeScanDone:^{
         [self.plugin returnSuccess:text format:format cancelled:FALSE 
flipped:FALSE callback:self.callback];
            }];`
    
    I'll try to send a pull request to the barcode scanner plugin with this fix 
this afternoon.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to