![](/img/trans.png)
[英]How to host a dynamic AngularJS web app in AWS and access it in browser
[英]How to know that web app is access on browser or from teams custom app
我的 web 应用程序是在 angular 中创建的。 我可以检查是否从浏览器或团队自定义应用程序访问 web 应用程序。
据我所知,此功能可用于在 react 中创建的应用程序。 示例:- 从“msteams-react-base-component”导入 { useTeams }; const [{ inTeams, 主题, 上下文}] = useTeams();
上面的 inTeams 返回 boolean,它告诉应用程序是从浏览器还是自定义应用程序访问。
所以我也在 angular 中得到这个?
您可以从 msteams-react-base-component 获取 function,非常简单:
import * as microsoftTeams from "@microsoft/teams-js";
export const checkInTeams = (): boolean => {
// eslint-disable-next-line dot-notation
const microsoftTeamsLib = microsoftTeams || window["microsoftTeams"];
if (!microsoftTeamsLib) {
return false; // the Microsoft Teams library is for some reason not loaded
}
if ((window.parent === window.self && (window as any).nativeInterface) ||
window.name === "embedded-page-container" ||
window.name === "extension-tab-frame") {
return true;
}
return false;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.