I tried to find a solution here but couldn't.
The problem is the following:
It works fine except when its opened from the webView "browser" from within the facebook app or chat on a phone.
So far I can see that the webView limitation is that you can only have one active tab. So when page A is not active its javascript code is not executed and the popup wont be closed.
You can test this with this fiddle from the webView browser.
let w = null;
window.addEventListener("DOMContentLoaded", (event) => {
document.querySelector("button").addEventListener("click", () => {
w = window.open("https://www.google.com", "customPopup", popupFeatures);
window.setTimeout(() => {
if (w) { w.close() }
alert('parent js is working');
}, 3000);
});
});
const popupFeatures =
"menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width=700,height=700";
<button>.......CLICK here....</button>
Some limitations I cant circumvent:
Is there a way to keep the javascript code on page A to keep executing or being able to close the popup?
The main problem is after the popup opens and the user finishes with the authentication the flow is stuck there because I cant close it from page A since its javascript thread is not active.