Benjith commented on issue #891:
URL: 
https://github.com/apache/cordova-plugin-camera/issues/891#issuecomment-2304555513

   I had almost same isssue. i fixed by changing package
   import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
   
   and in camera function i need to check permission first
   
   const cameraPermission = await this.diagnostic.isCameraAuthorized();
   if (!cameraPermission) {
   await this.diagnostic.requestCameraAuthorization();
   }
   
   `async takePicture(record, attempt = 0) {
       try{
         const cameraPermission = await this.diagnostic.isCameraAuthorized();
         if (!cameraPermission) {
           await this.diagnostic.requestCameraAuthorization();
         }
         const options: CameraOptions = {
           quality: 100,
           destinationType: this.camera.DestinationType.DATA_URL, // or 
FILE_URI for file path
           encodingType: this.camera.EncodingType.JPEG,
           mediaType: this.camera.MediaType.PICTURE
         };
         this.camera.getPicture(options).then(
           (imageData) => {
             // If DATA_URL, imageData is a base64 encoded string
             // If FILE_URI, imageData is a file path
             this.capturedImage = 'data:image/jpeg;base64,' + imageData;
           },
           (err) => {
             console.log('Error capturing image', err);
           }
         );
       }catch(err){
         console.error('Error capturing image:', err);
         this.showAlert('Error', 'Unable to take picture. Error code: ' + err);
       }
     }
     async showAlert(header: string, message: string) {
       const alert = await this.alertCtrl.create({
         header,
         message,
         buttons: ['OK']
       });
       await alert.present();
     }`
   checked in android 14(sdk 34)


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

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


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

Reply via email to