Ionic Cordova calls native hardware API implementation camera photo

Official website: https://ionicframework.com/docs/native/camera

Chinese: http://www.ionic.wang/native_doc-index-id-121.html< /p>

1. Install cordava plugin

ionic cordova plugin add cordova-plugin-camera
npm install @ionic-native/camera

2. Introduce and register the corresponding module in app.module.ts

import {Camera} from'@ionic-native/camera/ngx';
    ...
@NgModule({
    ...
    providers: [
        ...
        Camera
        ...
    ]
    ...
})
export class AppModule {}

3. Import and read the document in the used page

import {Camera, CameraOptions} from'@ionic-native/camera/ngx';

constructor(private camera: Camera) {}

...


const options: CameraOptions = {
  quality: 100,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE
}

this.camera.getPicture(options).then((imageData) => {
 // imageData is either a base64 encoded string or a file URI
 // If it‘s base64 (DATA_URL):
 let base64Image = ‘data:image/jpeg;base64,‘ + imageData;
}, (err) => {
 // Handle error
});

ionic cordova plugin add cordova-plugin-camera
npm install @ionic-native/camera

import {Camera} from ‘@ionic-native/camera/ngx’;
    ...
@NgModule({
    ...
    providers: [
        ...
        Camera
        ...
    ]
    ...
})
export class AppModule {}

import {Camera, CameraOptions} from ‘@ionic-native/camera/ngx’;

constructor(private camera: Camera) {}

...


const options: CameraOptions = {
  quality: 100,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE
}

this.camera.getPicture(options).then((imageData) => {
 // imageData is either a base64 encoded string or a file URI
 // If it‘s base64 (DATA_URL):
 let base64Image = ‘data:image/jpeg;base64,‘ + imageData;
}, (err) => {
 // Handle error
});

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3775 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.