Allows overriding a platform's default getWindowContext behavior. All calls to Platform.getWindowContext will pass through the override.
Example
const overrideCallback = (PlatformProvider) => {
class Override extends PlatformProvider {
async getWindowContext(payload, callerIdentity) {
// Perhaps in our platform, we wish to make window context available only to views from a given domain.
const { entityType } = callerIdentity;
if (entityType === 'view') {
const { url } = await fin.View.wrapSync(callerIdentity).getInfo();
if (!url.startsWith('https://my.trusted-domain.com')) {
throw new Error('Only apps from trusted domains may use window context in this platform.');
}
}
return super.getWindowContext(payload, callerIdentity);
}
}
return new Override();
}
fin.Platform.init({ overrideCallback });