Bug: E-mail - Opening PDF attachment in iOS PWA will result inability to close the PDF in PWA context
Dear Merijn,
I noticed that you're going to rewrite the e-mail module in future versions. One thing about opening attachments in iOS PWA instance is that the opening will trigger a new tab which will cause the PWA application to be in a state where user will have to close the application to use the application after the PDF has been opened. Because iOS does not allow users to close the opened tab after it has been opened.
One solution is to open it in a new GO.Window instance while iFraming the attachment. Because Safari and basically all mobile browsers do not support multi-page iFrame of PDF as browser will make the PDF into a pseudo object instead of a PDF this results users not seeing all pages in the attachement we will have to use following hack...
To solve this I have used pdfJS web viewer and this way users are able to see the whole PDF in the iframe which is inside the GO.Window instance.
Here is the modified openAttachment function in MessagePanel.js. Note that I have added pdfjs library in /views/Extjs3/javascript/ folder. This works quite nicely in mobile so maybe its something you can think about.
Regards, Thomas
openAttachment : function(e, target)
{
if(e.browserEvent.detail > 1) {
//prevent double clicking
return;
}
if(target.id.substr(0,this.attachmentsId.length)==this.attachmentsId)
{
var attachment_no = target.id.substr(this.attachmentsId.length+1);
var attachment = this.data.attachments[attachment_no];
if (go.util.isMobileOrTablet() ) {
if (attachment.extension == 'pdf') {
let uniqueid = Ext.id();
let eastPanel = new Ext.Panel({
layout: 'fit',
height:dp(800),
html: '<iframe width="100%" height="90%" style="border: none;" id="' + uniqueid +'" ></iframe>'
});
let win = new GO.Window({
title: attachment.name,
items: eastPanel,
height:dp(1000)
});
win.show();
setTimeout(() => {
document.getElementById(uniqueid).setAttribute('src', '/views/Extjs3/javascript/pdfjs/web/viewer.html?file='+encodeURIComponent('/'+attachment.url));
},100)
}
} else {
this.fireEvent('attachmentClicked', attachment, this);
}
}
Thanks! We'll make this when we refactor e-mail.
PS: You can go back now by swiping from left to right. Not ideal but it works.