You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/01/11 16:57:02 UTC

[GitHub] [cordova-plugin-camera] oscarsales opened a new issue #703: Update plugin with iOS UI Thread bug solved

oscarsales opened a new issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703


   # Feature Request
   
   I've created this post as a **feature request** although it's a bug because this is a well known bug of this plugin, and the solution is also known, so should have been solved long time ago. If you google it you can find some posts about it on stackoverflow and github.
   
   What I'm requesting is a new version of the plugin with this fix.
   
   ## Feature Description
   
   When you open the picker in iOS (gallery or camera) the first time it takes A LOT of time to open, in my case around 15 seconds. This happens because the native code opens the picker **outside** the UI thread. When it opens you can find the console flooded with these warnings:
   
   `Main Thread Checker: UI API called on a background thread.`
   
   
   ## Motivation Behind Feature
   
   I found some people complaining about this and waiting for a solution. In my case, I develop apps for clients who report this problem to me. Furthermore I work with more people in a repository, so every time someone downloads the project the plugin is reinstalled and the error persists. For now I fixed it with the workaround below, but this is just a temporary solution, we've had this fix for months, waiting for this plugin to publish a new version with this error fixed.
   
   I imagine that the devs who manage this plugin are busy with other issues before launching a new version and I guess this problem must be already queued, I understand. However this is a priority, not to me but because the iOS version is not usable. Without this fix, this plugin for iOS is useless.
   
   ## Alternatives or Workarounds
   
   As answered in [this topic](https://stackoverflow.com/questions/58038810/xcode-10-main-thread-checker-cordova-camera-plugin), the solution is very easy:
   
   CDVCamera.m, line 186, method **showCameraPicker**(),
   move the first lines into the "dispatch_async" block:
   
   ```
   - (void)showCameraPicker:(NSString*)callbackId withOptions:(CDVPictureOptions *) pictureOptions
   {
        /////// IT WAS HERE
   
       // Perform UI operations on the main thread
       dispatch_async(dispatch_get_main_queue(), ^{
           
           //////// <----- NOW HERE
           CDVCameraPicker* cameraPicker = [CDVCameraPicker createFromPictureOptions:pictureOptions];
           self.pickerController = cameraPicker;
   
           cameraPicker.delegate = self;
           cameraPicker.callbackId = callbackId;
           cameraPicker.webView = self.webView;
           //////// 
   ```
   
   With this simple change it works correctly and the alert in the console disappears.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] jcesarmobile closed issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
jcesarmobile closed issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] jcesarmobile commented on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
jcesarmobile commented on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-777634898


   this was fixed in 5.0.0


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] clearbrian commented on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
clearbrian commented on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773472042


   Im not sure this is the right place to wrap the code in main q It needs to be done further up where user is asked for permission to access camera and where the code back goes into the background.
   The issue is caused further up in 
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   theres a call to 
    [self.commandDelegate runInBackground:^{ 
    Then it checks permissions.
    requestAccessForMediaType
    
    if user refuses it shows an Alert. This is wrapped in main_q
     but theres two other ways out of the method which should also be wrapped in mainq because later they launch CDVCameraPicker in showCameraPicker:withOptions:
     
     
    if user accepts permission or ALREADY has permission then it calls this method twice in 
    [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
    BUT
    its still in the background thread clause
    
   FIX it to wrap these two in main_q as well.
   
   
   `                 } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }`
   
   
   FULL METHOD
   `- (void)takePicture:(CDVInvokedUrlCommand*)command
   {
       self.hasPendingOperation = YES;
       __weak CDVCamera* weakSelf = self;
   
       [self.commandDelegate runInBackground:^{
           CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
           pictureOptions.popoverSupported = [weakSelf popoverSupported];
           pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
           pictureOptions.cropToSize = NO;
   
           BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType];
           if (!hasCamera) {
               NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)pictureOptions.sourceType);
               CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No camera available"];
               [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];
               return;
           }
   
           // Validate the app has permission to access the camera
           if (pictureOptions.sourceType == UIImagePickerControllerSourceTypeCamera) {
               [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
                {
                    if(!granted)
                    {
                        // Denied; show an alert
                        dispatch_async(dispatch_get_main_queue(), ^{
                            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil) preferredStyle:UIAlertControllerStyleAlert];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Settings", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [weakSelf.viewController presentViewController:alertController animated:YES completion:nil];
                        });
                    } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }`
   
   
   
   
   
   
   
   
   
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] clearbrian edited a comment on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
clearbrian edited a comment on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773472042






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] breautek commented on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773479087


   @clearbrian Looks like you've done some thorough research, development and testing here. It would be great if this could be prepared in a pull request. One of our PMC volunteers that has experience in iOS development will eventually be able to review the suggested code change.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] clearbrian edited a comment on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
clearbrian edited a comment on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773472042


   Im not sure this is the right place to wrap the code in main q It needs to be done further up where user is asked for permission to access camera and where the code back goes into the background.
   The issue is caused further up in 
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   theres a call to 
    [self.commandDelegate runInBackground:^{ 
    Then it checks permissions.
    requestAccessForMediaType
    
    if user refuses it shows an Alert. This is wrapped in main_q
     but theres two other ways out of the method which should also be wrapped in mainq because later they launch CDVCameraPicker in showCameraPicker:withOptions:
     
     
    if user accepts permission or ALREADY has permission then it calls this method twice in 
    [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
    BUT
    its still in the background thread clause
    
   FIX it to wrap these two in main_q as well.
   
   
   `                 } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }`
   
   
   FULL METHOD
   
   ```
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   {
       self.hasPendingOperation = YES;
       __weak CDVCamera* weakSelf = self;
   
       [self.commandDelegate runInBackground:^{
           CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
           pictureOptions.popoverSupported = [weakSelf popoverSupported];
           pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
           pictureOptions.cropToSize = NO;
   
           BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType];
           if (!hasCamera) {
               NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)pictureOptions.sourceType);
               CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No camera available"];
               [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];
               return;
           }
   
           // Validate the app has permission to access the camera
           if (pictureOptions.sourceType == UIImagePickerControllerSourceTypeCamera) {
               [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
                {
                    if(!granted)
                    {
                        // Denied; show an alert
                        dispatch_async(dispatch_get_main_queue(), ^{
                            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil) preferredStyle:UIAlertControllerStyleAlert];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Settings", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [weakSelf.viewController presentViewController:alertController animated:YES completion:nil];
                        });
                    } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }
   ```
   
   
   
   
   
   
   
   
   
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] clearbrian edited a comment on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
clearbrian edited a comment on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773472042


   Just noticed this bug too.
   Tapped on attach icon and sometimes nothing happening.
   When I run the iOS project I see background thread warnings in createFromPictureOptions:
   Access in CDVCameraPicker on background thread.
   
   The fix mentioned in the previous comment will work only if user accepts permission.
   Theres two other cases - user says no and app has permission already.
   
   
   The issue is caused further up in 
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   - 
   theres a call to start a background thread
   
    [self.commandDelegate runInBackground:^{ 
   
    Then it asks user for permissions
   
    requestAccessForMediaType
    
    if user refuses it shows an Alert. This is wrapped in main_q
   
   but theres two other ways out of the method which should also be wrapped in mainq because later they launch CDVCameraPicker in showCameraPicker:withOptions:
   and you see purple background thread warnings.
     
    if user accepts permission or ALREADY has permission then it calls this method twice in 
    [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
    BUT
    its still in the background thread clause
    
   FIX it to wrap these two in main_q as well.
   
   
   ```
                    } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }
   ```
   
   
   FULL METHOD
   
   ```
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   {
       self.hasPendingOperation = YES;
       __weak CDVCamera* weakSelf = self;
   
       [self.commandDelegate runInBackground:^{
           CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
           pictureOptions.popoverSupported = [weakSelf popoverSupported];
           pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
           pictureOptions.cropToSize = NO;
   
           BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType];
           if (!hasCamera) {
               NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)pictureOptions.sourceType);
               CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No camera available"];
               [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];
               return;
           }
   
           // Validate the app has permission to access the camera
           if (pictureOptions.sourceType == UIImagePickerControllerSourceTypeCamera) {
               [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
                {
                    if(!granted)
                    {
                        // Denied; show an alert
                        dispatch_async(dispatch_get_main_queue(), ^{
                            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil) preferredStyle:UIAlertControllerStyleAlert];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Settings", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [weakSelf.viewController presentViewController:alertController animated:YES completion:nil];
                        });
                    } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }
   ```
   
   
   
   
   
   
   
   
   
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] breautek commented on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773479087


   @clearbrian Looks like you've done some thorough research, development and testing here. It would be great if this could be prepared in a pull request. One of our PMC volunteers that has experience in iOS development will eventually be able to review the suggested code change.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] clearbrian commented on issue #703: Update plugin with iOS UI Thread bug solved

Posted by GitBox <gi...@apache.org>.
clearbrian commented on issue #703:
URL: https://github.com/apache/cordova-plugin-camera/issues/703#issuecomment-773472042


   Im not sure this is the right place to wrap the code in main q It needs to be done further up where user is asked for permission to access camera and where the code back goes into the background.
   The issue is caused further up in 
   - (void)takePicture:(CDVInvokedUrlCommand*)command
   theres a call to 
    [self.commandDelegate runInBackground:^{ 
    Then it checks permissions.
    requestAccessForMediaType
    
    if user refuses it shows an Alert. This is wrapped in main_q
     but theres two other ways out of the method which should also be wrapped in mainq because later they launch CDVCameraPicker in showCameraPicker:withOptions:
     
     
    if user accepts permission or ALREADY has permission then it calls this method twice in 
    [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
    BUT
    its still in the background thread clause
    
   FIX it to wrap these two in main_q as well.
   
   
   `                 } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }`
   
   
   FULL METHOD
   `- (void)takePicture:(CDVInvokedUrlCommand*)command
   {
       self.hasPendingOperation = YES;
       __weak CDVCamera* weakSelf = self;
   
       [self.commandDelegate runInBackground:^{
           CDVPictureOptions* pictureOptions = [CDVPictureOptions createFromTakePictureArguments:command];
           pictureOptions.popoverSupported = [weakSelf popoverSupported];
           pictureOptions.usesGeolocation = [weakSelf usesGeolocation];
           pictureOptions.cropToSize = NO;
   
           BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:pictureOptions.sourceType];
           if (!hasCamera) {
               NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)pictureOptions.sourceType);
               CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No camera available"];
               [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId];
               return;
           }
   
           // Validate the app has permission to access the camera
           if (pictureOptions.sourceType == UIImagePickerControllerSourceTypeCamera) {
               [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
                {
                    if(!granted)
                    {
                        // Denied; show an alert
                        dispatch_async(dispatch_get_main_queue(), ^{
                            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.", nil) preferredStyle:UIAlertControllerStyleAlert];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Settings", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                                [weakSelf sendNoPermissionResult:command.callbackId];
                            }]];
                            [weakSelf.viewController presentViewController:alertController animated:YES completion:nil];
                        });
                    } else {
                        //BC added main thread call - when user Attaches photo camera picker was being called on background thread
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
                        });
                    }
                }];
           } else {
               dispatch_async(dispatch_get_main_queue(), ^{
                   [weakSelf showCameraPicker:command.callbackId withOptions:pictureOptions];
               });
               
           }
       }];
   }`
   
   
   
   
   
   
   
   
   
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org