-
Notifications
You must be signed in to change notification settings - Fork 6
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
bubble app postMessage experiment #2067
Comments
➤ Tammy Yang commented: SamEthan Wu I think this is something that we can give it a try https://bubble.io/plugin/%F0%9F%90%9D--iframe-complete-embed-1657267144487x391836917536391200 ( https://bubble.io/plugin/%F0%9F%90%9D--iframe-complete-embed-1657267144487x391836917536391200 ) |
➤ Sam commented: Tammy Yang, Ethan Wu any progress on this experiment? |
➤ Ethan Wu commented: Sam no progress on this experiment. can you provide me with more details on this one? i'm not exactly sure what we needs to be done |
➤ Sam commented: Ethan Wu, currently we need a way of communication between ionic and iframe. Maybe this claap ( https://app.claap.io/numbers-protocol/dev-bubble-app-post-message-api-c-O35CsUM4Uy-uwvX6bPoxJIB ) be a good intro. For example, on explore tab, we need to navigate to the root of the iframe. It supposes to be 3 simple steps.
But because ionic is host is localhost and iframe host is captureappiframe.numbersprotocol.io at step #3 we will get SecurityError: Blocked a frame with origin from accessing a cross-origin frame. This StackOverflow ( https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame ) explains better 😅 To solve this we can do B. use post Window.postMessage() ( https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage ) (will solve android back button issue) Another example using option B (aka postMessage()), lets say user
then user presses android back button (currently nothing will happen) But using postMessage() we can do the following (when user presses back button)
Please let me know if you have any questions. |
➤ Sam commented: I'm not sure if we need this bubble plugin ( https://bubble.io/plugin/%F0%9F%90%9D--iframe-complete-embed-1657267144487x391836917536391200 )to be able to use postMessage() or not. But the main idea is to use postMessage() API to communicate between iframe and capture app. |
➤ Ethan Wu commented: Sam thanks for the clarification. I'm thinking we don't need to use the plugin. I can try to add an html element to the page with the <script> message listener and see if that works. |
➤ Ethan Wu commented: Sam so will this work if the origins are different? |
➤ Sam commented: Ethan Wu, yes it supposes to work even if the origins are different. |
➤ Sam commented: Ethan Wu, do you have any experimental pages so I can play around from the ionic side? |
➤ Ethan Wu commented: Sam i'm still investigating this. i'll let you know when i've made some progress |
➤ Sam commented: Ethan Wu, just want to ask if have you ever had this issue before. Currently I'm trying to use my-experiment bubble app in capture app iframe but getting error. Maybe you had similar error when dealing with https://captureappiframe.numbersprotocol.io Here is the [claap ( https://app.claap.io/numbers-protocol/ethan-bubble-iframe-experiment-c-O35CsUM4Uy-3tAaTIwyzl5G )] |
➤ Sam commented: Oh now I know I just need to enable Allow to render the app in a frame/iframe (X-Frame-Options)from Settings.YouTube ( https://youtu.be/N7AoUpVwzbc?t=84 ) 😅 |
➤ Ethan Wu commented: Sam so i think its possible to add a script to bubble app body but it will require a paid account in order to activate the functionality |
➤ Sam commented: Ethan Wu, do you mean to add a postMessage listener to the body and not for every page? window.addEventListener('message', event => { // IMPORTANT: check the origin of the data! |
➤ Sam commented: Ethan Wu, is it possible to add window.addEventListener('message') to body? Currently I run JS on page load and the bad thing is we need to add listener to all pages where we need to android back button to work. By the way I'm available for calls if it speeds up the conversation. |
➤ Ethan Wu commented: yes. see here: |
➤ Ethan Wu commented: i'm trying this experiment out now |
➤ Ethan Wu commented: ok so i've successfully added it to the page body Sam |
➤ Sam commented: Can we have a call or claap on that for better understanding |
➤ Ethan Wu commented: Sam |
➤ Ethan Wu commented: yes lets have a call. huddle? |
➤ Sam commented: sure |
➤ Sam commented: Ethan Wu, it should work if you pass as a second parameter https://captureappiframe.numbersprotocol.io ( https://captureappiframe.numbersprotocol.io/version-v221107-ethan-from-qa/ ) So in html script change it from postMessage(message) |
➤ Ethan Wu commented: Sam so what do want me to change? |
➤ Sam commented: Can I see the sandbox code please? |
➤ Sam commented: Can I see the sandbox code please? from https://ltvdsf.csb.app/ ( https://ltvdsf.csb.app/ ) for sending postMessage() |
➤ Ethan Wu commented: var button = document.querySelector("#sendMessage"); function sendMessage() { button.addEventListener("click", sendMessage); |
➤ Ethan Wu commented: oh i see |
➤ Ethan Wu commented: replace "*" with the iframe url |
➤ Sam commented: iframe.contentWindow.postMessage(message, "https://captureappiframe.numbersprotocol.io ( https://captureappiframe.numbersprotocol.io/version-v221107-ethan-from-qa/ )") |
➤ Ethan Wu commented: ok it works! |
➤ Sam commented: Ethan Wu, so you can see message from bubble side right? |
➤ Ethan Wu commented: Sam yes |
➤ Ethan Wu commented: let me know if the above is the expected result |
➤ Sam commented: Ethan Wu,saw you claap, yes exactly. So we can change the global script to something like window.addEventListener('message', event => { I recorded similar claap ( https://app.claap.io/numbers-protocol/ethan-another-working-example-c-O35CsUM4Uy-MsHW_JDdTlOt ) |
➤ Ethan Wu commented: ok i can make the adjustment to the script. |
➤ Sam commented: Ethan Wu, just to confirm tested your URL ( https://captureappiframe.numbersprotocol.io/version-v221107-ethan-from-qa/ ) and it's working. [claap ( https://app.claap.io/numbers-protocol/ethan-working-preview-of-iframe-communication-of-android-back-button-c-O35CsUM4Uy-6HRi3xF5Hel5 )] This can be considered as completed. |
➤ Ethan Wu commented: Sam awesome. thanks for the support |
➤ Ethan Wu commented: Sam one thing you might need to consider on the ionic side is when users navigate through capture iframe the url changes. for example: explorer => baseurl so when you send message in |
➤ Ethan Wu commented: nvm i just saw your claap. no issues haha |
➤ Sam commented: Ethan Wu, I'm not sure about that 😅. I believe just need to be origin ( https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage ). |
➤ Ethan Wu commented: it seemed to work fine in your claap so i think it should be fine. |
➤ Sam commented: Ethan Wu, (cc: Kenny Hung) added data policy iframe is working. Once URL for "Terms of use" will be provided we can consider it as completed. |
➤ Kenny Hung commented: Sam The order should be
|
➤ Tammy Yang commented: Kenny Hung if you are talking about the "Settings", it should be Wallet |
➤ Tammy Yang commented: I will open a new task for the updates |
➤ Tammy Yang commented: [Sprint 2] Update Menu ( https://app.asana.com/0/1201016280880500/1203594105954143/f ) |
Try to experiment and find out if adding an event listener in the bubble app is possible.
window.addEventListener('back-button-pressed-from-ionic-side', event => {
// IMPORTANT: check the origin of the data!
if (event.origin === 'https://our-ionic-site.com') {
// The data was sent from your site.
// Data sent with postMessage is stored in event.data:
console.log(event.data);
// This is good place to navigate back etc.
} else {
// The data was NOT sent from our ionic app!
// Be careful! Do not use it. This else branch is
// here just for clarity, you usually shouldn't need it.
return;
}
});
More details at
https://stackoverflow.com/a/25098153/6133329┆Issue is synchronized with this Asana task by Unito
┆Created By: Sam
The text was updated successfully, but these errors were encountered: