torn-pda icon indicating copy to clipboard operation
torn-pda copied to clipboard

postMessage not working

Open JJins opened this issue 3 years ago • 4 comments
trafficstars

When I do something like window.open and post data to that new open window in a user script, nothing works. That window couldn’t receive any message. Same code works well on safari browser or alook app. Trying this scripts on android. Platform: ios App version: 2.6.3

JJins avatar Dec 29 '21 10:12 JJins

Hi, thanks. Could you provide a small example? I'm not really sure if that's possible with the webview implementation.

Your other tests (Safari, etc.) are on mobile or desktop? You said you are trying on Android, but then also mentioned iOS as a platform.

Manuito83 avatar Dec 29 '21 10:12 Manuito83

iOS Pda

tab A:

let newWindow = window.open('https://example.com')
window.setInterval(()=>{
  newWindow.postMessage('connect', '*')
},1000)

tab B (newWindow):

window.addEventListener("message", (e) => {
  console.log(e.data);
}, false);

tab B (newWindow) couldn't get any message from tab A.

JJins avatar Dec 29 '21 16:12 JJins

Sorry for the late reply, we are RWing... I usually use iOS device, did not have a chance to test this on some Android devices. But I tested this api works well on other Browser. BTW PDA is awsome, many of our members are using your app. Thanks a lot for your contribution!

JJins avatar Dec 29 '21 17:12 JJins

Thanks! I'll have a look when I can. I don't think there is direct communication between tabs due to framework restrictions, but there might be a way around it with the webview implementation I use.

Manuito83 avatar Jan 02 '22 11:01 Manuito83