File opener is open after hitting backbutton of mobile phone

I have a issue this is my function for download and open the pdf file in mobile app

letProcessReportCard(Url) {
var currentDate = new Date();
var currentTimeStamp = currentDate.getTime()
let path = this.file.dataDirectory;
const transfer = this.transfer.create();, path + ${currentTimeStamp}.pdf).then(entry => {
let url = entry.toURL();
console.log(‘the url is as’, url);
if (‘ios’)) {
this.document.viewDocument(url, ‘application/pdf’, {});
else {, ‘application/pdf’)
.then(() =>
console.log(‘File is opened’))
.catch(e => console.log(‘Error opening file’, e));

in this code when i click on submit button loader is start until the file downloaded from the server and hide loader after download then open file using file opener workd perfectly but if i click on submit button loader starts and if i click on back button loader stop but the file still open after few seconds. I want to stop to open the file if user click backbutton between downloading the file. please help

todo like this

fetch(‘data:application/pdf;base64,’ + this.downloadPDFStream, { method: “GET” }).then(res => res.blob()).then(blob => {
this.file.writeFile(this.file.externalApplicationStorageDirectory, this.fileName, blob, { replace: true }).then(res => {
this.FileResponse = res;
/, ‘application/pdf’).then((resFileOpener) => {
}).catch(err => { console.log(‘open error’) });
this.socialsharing.share(“test”, null, this.FileResponse.toInternalURL().replace(“cdvfile”, “file”), null);
}).catch(err => {
console.log(‘save error’);
}).catch(err => {