Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagehtml
<iframe src="https://{partition}.pricefx.com" id="pfx-iframe"
        sandbox="allow-scripts allow-same-origin allow-forms allow-popups"/>

Parameters needed for the iframe:

Parameter

Description

src

https://{partition}.pricefx.com

id

can be anything, depends on external application

sandbox

minimum permissions needed by Pricefx Unity front-end

The external application front-end can communicate with Pricefx Unity front-end through the Unity Messaging API.

Implementation example

As you embed Unity inside another external application:

You can start using it with the code below:

Code Block
languagejs
const iframe = document.getElementById('pfx-iframe');
const messageHandler = (event) => console.log(event.data);
window.addEventListener(messageHandler);
iframe.contentWindow.postMessage({
  "source": "pfxParentMessage",
  "type": "getUserData"
}, *);

In this case, you will attach a handler that logs the message it receives from Unity, and also will message Unity requesting the logged in user data.

On the other side, if you have an external application embedded in Unity:

Code Block
languagejs
const messageHandler = (event) => console.log(event.data);
window.addEventListener(messageHandler);
window.parent.postMessage({
  "source": "pfxParentMessage",
  "type": "getUserData"
}, *);

And you will have the same behavior as described for the first case.