From 89a4805e03bce69846215da8923cf69ea0d51608 Mon Sep 17 00:00:00 2001 From: Jim Johnson Date: Tue, 5 Nov 2024 14:22:28 -0800 Subject: [PATCH] DMX-4579 update postmessage example (#267) * Adding uk01 zone to postMessage example and supporting text. * Additional content --- building_applications/building_side_panel_apps.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/building_applications/building_side_panel_apps.md b/building_applications/building_side_panel_apps.md index 8b8f914..d1a53d9 100644 --- a/building_applications/building_side_panel_apps.md +++ b/building_applications/building_side_panel_apps.md @@ -338,6 +338,8 @@ The information retrieved from a message event sent from the parent window inclu To access context data using the MessageEvent interface, add an event listener to your page and the `postMessage` method to initialize communication with the parent window. Here is some example code that demonstrates retrieving context data from the message event object. Note the use of conditional statements with the `postMessage` method to account for [Multiple Procore Regions]({{ site.url }}{{ site.baseurl }}{% link tutorials/tutorial_mpz.md %}). +Be sure to account for all regions where your application needs to retrieve Procore context. +Be aware that as new Procore regions become available, your `postMessage` code must be updated to support these new regions. ```javascript window.addEventListener('message', (event) => { @@ -350,8 +352,9 @@ window.addEventListener('message', (event) => { const resource_id = obj.context.id; }}); -if (document.referrer === "https://us02.procore.com/") { window.parent.postMessage({ type: 'initialize' }, "https://us02.procore.com/"); } if (document.referrer === "https://app.procore.com/") { window.parent.postMessage({ type: 'initialize' }, "https://app.procore.com/"); } +if (document.referrer === "https://us02.procore.com/") { window.parent.postMessage({ type: 'initialize' }, "https://us02.procore.com/"); } +if (document.referrer === "https://uk01.procore.com/") { window.parent.postMessage({ type: 'initialize' }, "https://uk01.procore.com/"); } ``` In the example above we have set the value for the `targetOrigin` parameter of the `postMessage` method to `https://example.com/my-side-panel-app`.