-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postMessage example from documentation doesn't work #420
Comments
Did you install the plugin from the master branch (version |
@dpa99c I got this to work with the following: I had to always use an |
That being said, do we have an idea of when this feature will become part of the release? Also, given that it's so easy to execute scripts inside of |
As illustrated in the documented example, the input must always be a stringified object: see here for reasons why. |
Above my pay grade 😄
A hacker could indeed inject code into a page to trigger the postMessage API, so your implementation which handles the |
That makes sense, @dpa99c, but I'm curious about the situation where a hacker could simply execute JS in a different site using this plugin. I know this is a bit broader than your PR but curious how to protect ourselves from this situation:
|
Since these things don't directly relate to postMessage API, and since they are questions rather than issues, it may be better to ask/discuss on Cordova Slack channels than here. |
Thanks for the quick responses, @dpa99c! Already using your code |
@FarhadG Im facing the exact same situation, but even switching to the master branch (3.1.0-dev) as @dpa99c mentioned, the "message" listener is never fired. Are there any extra steps you had to take to make this work? EDIT: Managed to make it work. If anyone gets stuck with this, the solution is to make something like this on the child page: |
The above solution will work on some devices (including my local one), however, I found it failed on some devices like Pixel 4, Galaxy S7, Pixel 3, Z Fold 4, etc.
This solution (with slight modification inspired by Leonavas strategy) appears to be more reliable (and also doesn't throw an error in typescript):
|
I need the ability to be able for an
inappbrowser
instance to communicate with the parent (theopener
). Given that there is noopener
object with theinappbrowser
, I've looked through repo's documentation and tests, and I cannot reproduce thepostMessage
API to communicate between aninappbrowser
instance and the main Cordova application (parent).Here's a simple example taken from the documentation/test within this repo:
The text was updated successfully, but these errors were encountered: