app module
发布时间:2026-09-21 | 浏览:2
Access to this page requires authorization. You can try signing in or changing directories .
Access to this page requires authorization. You can try changing directories .
Module to interact with app initialization and lifecycle.
Represents information about the application's host.
Represents application information.
Represents Channel information.
Represents Chat information.
Represents structure of the received context message.
Represents the failure request sent during an erroneous app initialization.
Represents the failed request sent during a failed app initialization.
Represents Meeting information.
The response of the notify success callback.
Represents Page information.
Represents information about a SharePoint site
Represents Team information.
Represents Tenant information.
Represents User information.
Features supported by the host that the app can query for via getContext.
This function is passed to registerHostToAppPerformanceMetricsHandler. It is called every time a response is received from the host with metrics for analyzing message delay. See HostToAppPerformanceMetrics to see which metrics are passed to the handler.
This function is passed to registerOnThemeHandler. It is called every time the user changes their theme.
Describes expected errors that occurred during an otherwise successful app initialization
Describes errors that caused app initialization to fail
Retrieves the current context the frame is running in.
Gets the Frame Context that the App is running in. See FrameContexts for the list of possible values.
Returns the immediate parent origin when this app is running inside an iframe.
Initializes the library.
Checks whether the Teams client SDK has been initialized.
Notifies the frame that app has loaded and to hide the loading indicator if one is shown.
Notifies the frame that app initialized with some expected errors.
Notifies the frame that app initialization has failed and to show an error page in its place.
Notifies the frame that app initialization is successful and is ready for user interaction.
This function opens deep links to other modules in the host such as chats or channels or general-purpose links (to external websites). It should not be used for navigating to your own or other apps.
Registers a function for handling data of host to app message delay.
Registers a handler for theme changes.
App Initialization Messages
Function Details
Retrieves the current context the frame is running in.
Promise< Context >
Promise that will resolve with the Context object.
get Frame Context()
Gets the Frame Context that the App is running in. See FrameContexts for the list of possible values.
FrameContexts | undefined
the Frame Context.
get Immediate Parent Origin()
Returns the immediate parent origin when this app is running inside an iframe.
The immediate parent origin, or null when unavailable.
This helper is useful for scenarios where the app must explicitly trust the hosting parent origin during initialize by passing [origin] as validMessageOrigins .
If no parent origin can be determined, this function returns null .
initialize(string[])
Initializes the library.
Optionally specify a list of cross-frame message origins. This parameter is used if you know that your app will be hosted on a custom domain (i.e., not a standard Microsoft 365 host like Teams, Outlook, etc.) Most apps will never need to pass a value for this parameter. Any domains passed in the array must define a scheme to be able to be processed. Examples: https://www.example.com , chrome://
Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
Initialize must have completed successfully (as determined by the resolved Promise) before any other library calls are made
is Initialized()
Checks whether the Teams client SDK has been initialized.
whether the Teams client SDK has been initialized.
notify App Loaded()
Notifies the frame that app has loaded and to hide the loading indicator if one is shown.
notify Expected Failure(IExpected Failure Request)
Notifies the frame that app initialized with some expected errors.
The expected failure request containing the reason and an optional message
notify Failure(IFailed Request)
Notifies the frame that app initialization has failed and to show an error page in its place.
The failure request containing the reason for why the app failed during initialization as well as an optional message.
notify Success()
Notifies the frame that app initialization is successful and is ready for user interaction.
Promise< NotifySuccessResponse >
open Link(string)
This function opens deep links to other modules in the host such as chats or channels or general-purpose links (to external websites). It should not be used for navigating to your own or other apps.
The host deep link or external web URL to which to navigate
Promise that will be fulfilled when the navigation has initiated. A successful Promise resolution does not necessarily indicate whether the target loaded successfully.
If you need to navigate to your own or other apps, use:
navigateToDefaultPage for navigating to the default page of your own app
navigateTo for navigating to a section of your own app
navigateToApp for navigating to other apps besides your own
Many areas of functionality previously provided by deep links are now handled by strongly-typed functions in capabilities. If your app is using a deep link to trigger these specific components, use the strongly-typed alternatives. For example (this list is not exhaustive):
To open an app installation dialog, use the appInstallDialog capability
To start a call, use the call capability
To open a chat, use the chat capability
To open a dialog, use the dialog capability
To create a new meeting, use the composeMeeting function
To open a Stage View, use the stageView capability
In each of these capabilities, you can use the isSupported() function to determine if the host supports that capability. When using a deep link to trigger these components, there's no way to determine whether the host supports it.
For more information on crafting deep links to the host, see Configure deep links
register Host ToApp Performance Metrics Handler(Host ToApp Performance Metrics Handler)
Registers a function for handling data of host to app message delay.
The handler to invoke when the metrics are available on each function response.
Only one handler can be registered at a time. A subsequent registration replaces an existing registration.
register OnTheme Change Handler(theme Handler)
Registers a handler for theme changes.
The handler to invoke when the user changes their theme.
Only one handler can be registered at a time. A subsequent registration replaces an existing registration.
Variable Details
App Initialization Messages
{ AppLoaded: string, ExpectedFailure: string, Failure: string, Success: string }
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?