Issue
My web application is created in angular. Can I check whether web application is accessed from browser or Teams custom apps.
As I know this features is available for app which are created in react. example :- import { useTeams } from "msteams-react-base-component"; const [{ inTeams, theme, context }] = useTeams();
Above inTeams return boolean, which tells whether app is accessed from browser or custom app.
So I get this in angular as well?
Solution
You can take the function from msteams-react-base-component, it's very simple:
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;
};
Answered By - eniel.rod
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.