import { Injectable } from '@angular/core'; import * as camera from 'nativescript-camera'; import { ImageSource } from 'tns-core-modules/image-source/image-source'; @Injectable({ providedIn: 'root' }) export class MyCameraService { constructor() { } takePicture(): Promise { var result = new Promise((resolve, reject) => { camera.requestPermissions(). then( () => { camera.takePicture().then( (imageAsset) => { var src = new ImageSource(); src.fromAsset(imageAsset).then( (source) => { resolve(source.toBase64String("png", 75)); } ); } ).catch((error) => alert(error.message)); }, () => { alert("Request rejected"); } ).catch(); }); return result; } }