diff --git a/how-to/register-with-home/public/common/views/contact/call-app/index.html b/how-to/register-with-home/public/common/views/contact/call-app/index.html index e433b97bad..3637d0686b 100644 --- a/how-to/register-with-home/public/common/views/contact/call-app/index.html +++ b/how-to/register-with-home/public/common/views/contact/call-app/index.html @@ -6,6 +6,7 @@ Call Application + diff --git a/how-to/register-with-home/public/common/views/contact/call-app/index.js b/how-to/register-with-home/public/common/views/contact/call-app/index.js index f74c2b9fc9..7cd441c56a 100644 --- a/how-to/register-with-home/public/common/views/contact/call-app/index.js +++ b/how-to/register-with-home/public/common/views/contact/call-app/index.js @@ -104,24 +104,38 @@ function initializeDOM() { await appChannel.broadcast(context); } - if (window.fdc3 !== undefined) { + /** + * Sets up the related fdc3 listeners once fdc3 is available. + */ + function setupListeners() { const startCallIntent = 'StartCall'; const openAppIntent = 'OpenApp'; - fdc3.addIntentListener(startCallIntent, (ctx, metadata) => { - console.log(`Received Context For Intent: ${startCallIntent}`, ctx, metadata); - updateCallInformation(ctx, startCallIntent); - return new Promise((resolve) => { - // To demonstrate getResult in fdc3 2.0 we simply return the context that was sent. - resolve(ctx); + try { + fdc3.addContextListener('fdc3.contact', (ctx, metadata) => { + console.log('Received Context', ctx, metadata); + updateCallInformation(ctx); }); - }); - fdc3.addIntentListener(openAppIntent, (ctx, metadata) => { - console.log(`Received Context For Intent: ${openAppIntent}`, ctx, metadata); - updateCallInformation(ctx, openAppIntent); - }); - fdc3.addContextListener('fdc3.contact', (ctx, metadata) => { - console.log('Received Context', ctx, metadata); - updateCallInformation(ctx); + fdc3.addIntentListener(startCallIntent, (ctx, metadata) => { + console.log(`Received Context For Intent: ${startCallIntent}`, ctx, metadata); + updateCallInformation(ctx, startCallIntent); + return new Promise((resolve) => { + // To demonstrate getResult in fdc3 2.0 we simply return the context that was sent. + resolve(ctx); + }); + }); + fdc3.addIntentListener(openAppIntent, (ctx, metadata) => { + console.log(`Received Context For Intent: ${openAppIntent}`, ctx, metadata); + updateCallInformation(ctx, openAppIntent); + }); + } catch (error) { + console.error('Error setting up all of the fdc3 listeners', error); + } + } + if (window.fdc3 !== undefined) { + setupListeners(); + } else { + window.addEventListener('fdc3Ready', async () => { + setupListeners(); }); } } diff --git a/how-to/register-with-home/public/common/views/contact/common/contacts.js b/how-to/register-with-home/public/common/views/contact/common/contacts.js index 2c9de045e1..37d14d7fb8 100644 --- a/how-to/register-with-home/public/common/views/contact/common/contacts.js +++ b/how-to/register-with-home/public/common/views/contact/common/contacts.js @@ -79,10 +79,17 @@ export function userToFdc3Context(user) { * @returns The custom settings from the manifest. */ async function getManifestCustomSettings() { - // Get the manifest for the current application - const app = await fin.Application.getCurrent(); + try { + if (window.fin) { + // Get the manifest for the current application + const app = await fin.Application.getCurrent(); - // Extract the custom settings for this application - const manifest = await app.getManifest(); - return manifest.customSettings ?? {}; + // Extract the custom settings for this application + const manifest = await app.getManifest(); + return manifest.customSettings ?? {}; + } + } catch { + // not inside of an OpenFin container or there isn't app support. + } + return {}; } diff --git a/how-to/register-with-home/public/common/views/contact/investments-and-models/index.html b/how-to/register-with-home/public/common/views/contact/investments-and-models/index.html index bb27b20a85..6eeea8e8fa 100644 --- a/how-to/register-with-home/public/common/views/contact/investments-and-models/index.html +++ b/how-to/register-with-home/public/common/views/contact/investments-and-models/index.html @@ -6,6 +6,7 @@ Investments & Models + diff --git a/how-to/register-with-home/public/common/views/contact/investments-and-models/index.js b/how-to/register-with-home/public/common/views/contact/investments-and-models/index.js index 97359789b7..71f36524d5 100644 --- a/how-to/register-with-home/public/common/views/contact/investments-and-models/index.js +++ b/how-to/register-with-home/public/common/views/contact/investments-and-models/index.js @@ -2,9 +2,24 @@ * Initialize the DOM. */ function initializeDOM() { - if (window.fdc3) { + if (window.fdc3 !== undefined) { + setupListeners(); + } else { + window.addEventListener('fdc3Ready', async () => { + setupListeners(); + }); + } +} + +/** + * Sets up the related fdc3 listeners once fdc3 is available. + */ +function setupListeners() { + try { window.fdc3.addContextListener(contextHandler); window.fdc3.addIntentListener('ViewContact', contextHandler); + } catch (error) { + console.error('There was an error while setting up all of the fdc3 listeners', error); } } diff --git a/how-to/register-with-home/public/common/views/contact/participant-history/index.html b/how-to/register-with-home/public/common/views/contact/participant-history/index.html index 4c468baec6..9477f2e6fb 100644 --- a/how-to/register-with-home/public/common/views/contact/participant-history/index.html +++ b/how-to/register-with-home/public/common/views/contact/participant-history/index.html @@ -6,6 +6,7 @@ Participant History + diff --git a/how-to/register-with-home/public/common/views/contact/participant-history/index.js b/how-to/register-with-home/public/common/views/contact/participant-history/index.js index 75de7f400e..5835e9a94f 100644 --- a/how-to/register-with-home/public/common/views/contact/participant-history/index.js +++ b/how-to/register-with-home/public/common/views/contact/participant-history/index.js @@ -2,9 +2,24 @@ * Initialize the DOM. */ function initializeDOM() { - if (window.fdc3) { + if (window.fdc3 !== undefined) { + setupListeners(); + } else { + window.addEventListener('fdc3Ready', async () => { + setupListeners(); + }); + } +} + +/** + * Sets up the related fdc3 listeners once fdc3 is available. + */ +function setupListeners() { + try { window.fdc3.addContextListener(contextHandler); window.fdc3.addIntentListener('ViewContact', contextHandler); + } catch (error) { + console.error('There was an error while setting up all of the fdc3 listeners', error); } } diff --git a/how-to/register-with-home/public/common/views/contact/participant-selection/index.html b/how-to/register-with-home/public/common/views/contact/participant-selection/index.html index 02183eb297..e6994a9576 100644 --- a/how-to/register-with-home/public/common/views/contact/participant-selection/index.html +++ b/how-to/register-with-home/public/common/views/contact/participant-selection/index.html @@ -6,6 +6,7 @@ Participant Selection +