I was trying to make my app stop relaunching when in background mode. Accordingly to the documentation, the Background Mode plugin (https://ionicframework.com/docs/native/background-mode) is the one to do fix it, but after I added and activated it now my apps stop working just before I try to open the camera or opening device files. Follow the app.component.ts code and after it the code that is called just before the app breaks:
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
this.backgroundMode.enable();
});
}
takePicture() {
const page = this;
page.camera.getPicture({
quality: 80,
destinationType: page.camera.DestinationType.FILE_URI,
encodingType: page.camera.EncodingType.JPEG,
mediaType: page.camera.MediaType.PICTURE
} as CameraOptions).then((imageURL) => {
const that = page;
// @ts-ignore
window.resolveLocalFileSystemURL(imageURL, function success(file) {
getFileSizeAndRun(file, (fileProc, fileSize) => {
console.log(fileProc);
that.storageFileUploadUtils.addUploadQueue({
id: new Date().getMilliseconds() * -1,
multipartFile: fileProc.file,
fileExtension: FileTypeEnum.JPG,
loading: true,
error: false,
fileSize,
originalName: fileProc.name
} as StorageFile);
that.loading = false;
that.changeRef.detectChanges();
});
}, () => console.log('trying to use this...'));
}, (err) => {
throw Error('Erro ao carregar recuperar a foto.');
});
}