How does Remote Control work
In the release notes for Web 5.3, it says
- Added the necessary hooks and commands to Geocortex Web to support embedded app scenarios where you have an application or a web page that wants to "remote control" Geocortex Web. These include a PostMessage listener to listen for external apps calling Geocortex Web commands, and a PostMessage command to allow Geocortex Web to post messages back to the containing app or web page.
Is there any information about how this is supposed to work? For example, I can open an iframe from a workflow, and now I'd like to send a message back to the viewer.
-
Hi Berend - we are still working on the SDK and documentation side of this, but I'm sure we can dig up an example for you to work from.
0 -
Thanks, that would be awesome.
0 -
Hi Berend. I've attached a zip containing the sample that shows basic usage of our post message bridge API.
Some important notes:
- You'll find the details of the Workflow used in the I Want To menu here: https://apps.geocortex.com/workflow/designer/#workflow=824b7f38a9604dd0aae7504af632641f
- You'll see in the app JSON configuration contains a setting "postMessageAllowedOrigin" used to configure the trusted origins of received messages. If not set correctly you'll notice that Web will not communicate with the other application for security reasons. See https://www.arcgis.com/sharing/rest/content/items/bc8fe8a09f7447739e962c951513e365/data?f=json for specifics
- The code for sending/receiving messages to/from Web can be found in the index.html of the attached zip
0 -
Hi Ian,
Thanks for this sample, it looks helpful.
If I understand things correctly, viewer.postmessage sends a message to the parent window, is that right? Is it also possible to send a message to an IFrame contained inside the Web Viewer?
And how do I setup the viewer to receive messages? app.json is not included in the zip file, so that part is not clear to me yet. If for instance I want to send a message to run a workflow, how can I include workflow in the viewer?
Berend
0 -
Hi Berend,
There are two patterns we envision for integrating GXW and other applications.
The first pattern is GXW as child. This means that another application invokes GXW and holds the keys to communication.
This is the case for the example we sent you, embedding GXW in a web page.
This would also be the pattern for integrating GXW with an external 3rd party application where that application opens and maintains the connection to GXW.
With this pattern:
- Communication from the other app to GXW happens via postMessage that GXW is listening for (you’ll find that in the html of the example)
- Communication from GXW to the other app happens via a postMessage command (you’ll find that wrapped in a workflow that Ian provided a link to). The app.json you asked about is also available via a link Ian provided.
The second pattern is GXW as parent. This means that GXW invokes the other application and holds the keys to communication.
This is the case for the example you asked about such as embedding a 3rd party application inside GXW.
We do not yet have a good example for this pattern, one will be coming with your GXW SDK.
What we intend is to always do this case by writing custom component.
The SDK example will demonstrate:
- The custom component contains an iframe
- The custom component initializes the 3rd party app inside its iframe and keeps the keys to communication
- The custom component has full access to the GXW commands/operations
- The custom component speaks to the 3rd party app inside its iframe using postMessage commands that deliver payloads understood by that 3rd party application
- The custom component also initializes postMessage listeners capable of receiving postMessage commands and payloads sent by that 3rd party application
The code inside the listener can then perform native GXW work in the listener code.
0 -
Hi Cam,
Thanks for the detailed answer. I can't wait for the SDK to come out, maybe something for the Christmas holidays? 😉
0 -
One more thing: I changed the message to call a workflow. The workflow is called, but I get an error in the browser's console:
Workflow inputs are not accepted from untrusted sources, to allow inputs enable acceptsUrlParams for the workflow with ID: 057a841a-bd35-4d43-b7b3-06f5a5330498
Where do I have to specify acceptUrlParams, and what value should it have?
0 -
Ah, yes. If you're launching a Workflow through the postMessage bridge, we only allow the execution of that Workflow if the Workflow configuration item has been configured in the app configuration with the acceptsUrlParams set to true (for security reasons). If you're editing the application configuration JSON for that app, you would change your workflow configuration item to look something like:
{
"id": "057a841a-bd35-4d43-b7b3-06f5a5330498",
"portalItem": "https://www.arcgis.com/sharing/rest/content/items/id-of-your-workflow-item",
"acceptsUrlParams": true,
"$type": "workflow"
}
This same configuration is what also allows you to execute workflows via a URL parameter when launching the viewer, and has similar security concerns.
After making that change and running it through the postMessage bridge it should work as expected!
0 -
Yes now it works, thanks.
BTW, it doesn't exactly work as you describe: The workflow does run, even without acceptUrlParams, it's just that no parameters were passed to the workflow. So if this is really meant to prevent workflows from running, something would be wrong.
0 -
I'll pass that along to the team to double check the intended behavior. Thanks Berend!
0 -
Someone mentioned the older example attached to this thread wasn't working ... here is a more up to date example: https://vertigis-web-samples.netlify.app/iframe
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
11 commentaires