calling-extensions-sdk
calling-extensions-sdk copied to clipboard
Calling SET_WIDGET_URL doesn't work before redirect to other URL
Checklist
- [x] I have read the FAQs.
- [x] I have checked the issue tracker for duplicate issues.
Description I cannot figure how to redirect to a different widget URL. I assume send message of type 'SET_WIDGET_URL' doesn't work. Here is my scenario:
I set an initial URL pointing to a decision server. It retrieves the portal ID, makes the API request to get the customer's url. Before redirect, I set 'SET_WIDGET_URL' with the new URL I do the redirect to the new URL. It is very similar to the issue #18 . The URLs are in format: company1.x.com, company2.x.com, company3.x.com and so on...
Expected behavior When I send a message of type messageType.SET_WIDGET_URL, I expect the iFrameManager stores the new host, so I can do the redirect to this URL, where a calling-extensions-sdk library will be initialized.
To Reproduce I am calling this message, but it has no effect:
cti.sendMessage({
type: 'SET_WIDGET_URL',
iFrameUrl: `https://newInstance.host.com/custom//index.html`
});
Screenshots/source code
<script>
const sizeInfo = {
width: 400,
height: 650,
};
const cti = new window.default({
debugMode: true,
eventHandlers: {
onReady: ({ engagementId, portalId, userId } = {}) => {
cti.initialized({ // The script was initialized to get portalId
engagementId,
isLoggedIn: false,
sizeInfo,
});
if (portalId) {
let newUrl = getUrlPlaceholder(); // We fetch URL based on portalId
cti.sendMessage({
type: 'SET_WIDGET_URL',
iFrameUrl: `https://${newUrl}`
});
window.location.assign(`https://${newUrl}/custom/index.html`); // I assume this script will initialize the library after redirect
}
},
},
});
</script>
Device information https://www.whatsmybrowser.org/b/UCQLI
Additional context I cleared the private information because of data protection. If you need further information, let me know.