@microsoft/teams-js package

Interfaces

AuthenticateParameters
RemoveEvent
SaveEvent
SaveParameters
Settings
Context
DeepLinkParameters
ShowNotificationParameters
TabInformation

Represents information about tabs for an app

TabInstance

Represents information about a tab instance

TabInstanceParameters

Indicates information about the tab instance for filtering purposes.

TaskInfo
TeamInformation

Represents Team Information

Enums

HostClientType
NotificationTypes
TaskModuleDimension
TeamType

Indicates the team type, currently used to distinguish between different team types in Office 365 for Education (team types 1, 2, 3, and 4).

UserTeamRole

Indicates the various types of roles of a user in a team.

Functions

enablePrintCapability()

Enable print capability to support printing page using Ctrl+P and cmd+P

getContext((context: Context) => void)

Retrieves the current context the frame is running in.

getMruTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Allows an app to retrieve the most recently used tabs for this user.

getTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Allows an app to retrieve for this user tabs that are owned by this app. If no TabInstanceParameters are passed, the app defaults to favorite teams and favorite channels.

initialize(any)

Initializes the library. This must be called before any other SDK calls but after the frame is loaded successfully.

navigateBack()

Navigates back in the Teams client. See registerBackButtonHandler for more information on when it's appropriate to use this method.

navigateCrossDomain(string)

Navigates the frame to a new cross-domain URL. The domain of this URL must match at least one of the valid domains specified in the validDomains block of the manifest; otherwise, an exception will be thrown. This function needs to be used only when navigating the frame to a URL in a different domain than the current one in a way that keeps the app informed of the change and allows the SDK to continue working.

navigateToTab(TabInstance)

Navigates the Microsoft Teams app to the specified tab instance.

print()

default print handler

registerBackButtonHandler(() => boolean)

Registers a handler for user presses of the Team client's back button. Experiences that maintain an internal navigation stack should use this handler to navigate the user back within their frame. If an app finds that after running its back button handler it cannot handle the event it should call the navigateBack method to ask the Teams client to handle it instead.

registerBeforeUnloadHandler((readyToUnload: () => void) => boolean)

Registers a handler to be called before the page is unloaded.

registerChangeSettingsHandler(() => void)

Registers a handler for when the user reconfigurated tab

registerFullScreenHandler((isFullScreen: boolean) => void)

Registers a handler for changes from or to full-screen view for a tab. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

registerOnThemeChangeHandler((theme: string) => void)

Registers a handler for theme changes. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

shareDeepLink(DeepLinkParameters)

Shares a deep link that a user can use to navigate back to a specific state in this page.

Function Details

enablePrintCapability()

Enable print capability to support printing page using Ctrl+P and cmd+P

function enablePrintCapability()

getContext((context: Context) => void)

Retrieves the current context the frame is running in.

function getContext(callback: (context: Context) => void)

Parameters

callback
(context: Context) => void

The callback to invoke when the <xref:Context> object is retrieved.

getMruTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Allows an app to retrieve the most recently used tabs for this user.

function getMruTabInstances(callback: (tabInfo: TabInformation) => void, tabInstanceParameters?: TabInstanceParameters)

Parameters

callback
(tabInfo: TabInformation) => void

The callback to invoke when the <xref:TabInformation> object is retrieved.

tabInstanceParameters
microsoft/teams-js.TabInstanceParameters

OPTIONAL Ignored, kept for future use

getTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Allows an app to retrieve for this user tabs that are owned by this app. If no TabInstanceParameters are passed, the app defaults to favorite teams and favorite channels.

function getTabInstances(callback: (tabInfo: TabInformation) => void, tabInstanceParameters?: TabInstanceParameters)

Parameters

callback
(tabInfo: TabInformation) => void

The callback to invoke when the <xref:TabInstanceParameters> object is retrieved.

tabInstanceParameters
microsoft/teams-js.TabInstanceParameters

OPTIONAL Flags that specify whether to scope call to favorite teams or channels.

initialize(any)

Initializes the library. This must be called before any other SDK calls but after the frame is loaded successfully.

function initialize(hostWindow?: any)

Parameters

hostWindow
any

Navigates back in the Teams client. See registerBackButtonHandler for more information on when it's appropriate to use this method.

function navigateBack()

Navigates the frame to a new cross-domain URL. The domain of this URL must match at least one of the valid domains specified in the validDomains block of the manifest; otherwise, an exception will be thrown. This function needs to be used only when navigating the frame to a URL in a different domain than the current one in a way that keeps the app informed of the change and allows the SDK to continue working.

function navigateCrossDomain(url: string)

Parameters

url
string

The URL to navigate the frame to.

Navigates the Microsoft Teams app to the specified tab instance.

function navigateToTab(tabInstance: TabInstance)

Parameters

tabInstance
microsoft/teams-js.TabInstance

The tab instance to navigate to.

default print handler

function print()

registerBackButtonHandler(() => boolean)

Registers a handler for user presses of the Team client's back button. Experiences that maintain an internal navigation stack should use this handler to navigate the user back within their frame. If an app finds that after running its back button handler it cannot handle the event it should call the navigateBack method to ask the Teams client to handle it instead.

function registerBackButtonHandler(handler: () => boolean)

Parameters

handler
() => boolean

The handler to invoke when the user presses their Team client's back button.

registerBeforeUnloadHandler((readyToUnload: () => void) => boolean)

Registers a handler to be called before the page is unloaded.

function registerBeforeUnloadHandler(handler: (readyToUnload: () => void) => boolean)

Parameters

handler
(readyToUnload: () => void) => boolean

The handler to invoke before the page is unloaded. If this handler returns true the page should invoke the readyToUnload function provided to it once it's ready to be unloaded.

registerChangeSettingsHandler(() => void)

Registers a handler for when the user reconfigurated tab

function registerChangeSettingsHandler(handler: () => void)

Parameters

handler
() => void

The handler to invoke when the user click on Settings.

registerFullScreenHandler((isFullScreen: boolean) => void)

Registers a handler for changes from or to full-screen view for a tab. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerFullScreenHandler(handler: (isFullScreen: boolean) => void)

Parameters

handler
(isFullScreen: boolean) => void

The handler to invoke when the user toggles full-screen view for a tab.

registerOnThemeChangeHandler((theme: string) => void)

Registers a handler for theme changes. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerOnThemeChangeHandler(handler: (theme: string) => void)

Parameters

handler
(theme: string) => void

The handler to invoke when the user changes their theme.

Shares a deep link that a user can use to navigate back to a specific state in this page.

function shareDeepLink(deepLinkParameters: DeepLinkParameters)

Parameters

deepLinkParameters
microsoft/teams-js.DeepLinkParameters

ID and label for the link and fallback URL.