Forum Discussion
Call URL Handler leads to crash in new Teams
ChetanSharma-msftI call window.open like this:
window.open("test-url-handler:email address removed for privacy reasons", "_self");
test-url-handler is a valid url handler registered in windows. If I call "test-url-handler:email address removed for privacy reasons" from a browser it actually opens the registered application as desired.
Thanks
Matthias
This issue is because of violation of Content Security Policy in Teams.
So, we will confirm with engineering team and let you know the updates whether it is not supported or a bug.
- vikram-MFSTMar 01, 2024Brass Contributor
Hello MatthiasAbele
we have got an update from our engineering team.
We've always had that CSP header in place for the Teams Web Client (T1 and T2.1); it's now also in effect for the New Teams Desktop Client (T2.1). This header is necessary to ensure the security. If you need to launch out to a native app via a custom protocol, you can use any one of these options:
1)Call window.open with target parameter set to "_blank" instead of "_self".
2)Use an anchor tag with target="_blank"
3)Call the https://learn.microsoft.com/en-us/javascript/api/@microsoft/teams-js/app?view=msteams-client-js-latest#@microsoft-teams-js-app-openlink or https://learn.microsoft.com/en-us/javascript/api/@microsoft/teams-js/?view=msteams-client-js-latest#@microsoft-teams-js-executedeeplink SDK API- MatthiasAbeleMar 01, 2024Copper Contributor
Thanks,vikram-MFST
Very valuable information. For all 3 options you gave me, the link is now working fine, no crashes.
But:
1) tel:+0000000000 is working
2) test-url-handler:email_address is NOT working
on 1) the correcty registered handler for tel: is called
on 2) nothing happens. When I use the openLink call, the Promise is correctly fulfilled, no errors thrown, but no URL handler outside is called.
Any idea?
Thanks a lot 🙂
- ChetanSharma-msftMar 01, 2024
Microsoft
Hello MatthiasAbele - As you are not getting any error, we are not able to investigate it further.
Did you try with using an anchor tag with target="_blank" or other suggested ways?