Tutorial: Platform.getWindowContext

Platform.getWindowContext

Get the context of the current window that was previously set using setWindowContext. Returns a promise that resolves to the context. This method can be called from the window itself, or from any child view. Context data is shared by all entities within a window.

Example 1: Retrieving context from current window

const platform = fin.Platform.getCurrentSync();
const customContext = { answer: 42 };
await platform.setWindowContext(customContext);

const myContext = await platform.getWindowContext();
console.log(myContext); // { answer: 42 }

Example 2: Retrieving the context of another window or view

const platform = fin.Platform.getCurrentSync();

const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };

const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
console.log(targetWindowContext); // context of target window