microsoftTeams module

Classes

ChildAppWindow
GlobalVars
ParentAppWindow

Interfaces

Context
DeepLinkParameters
FrameContext
IAppWindow
LocaleInfo

Represents OS locale info used for formatting date and time data

MessageRequest
MessageResponse
SdkError
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

ChannelType

The type of the channel with which the content is associated.

ErrorCode
FrameContexts
HostClientType
NotificationTypes
TaskModuleDimension

Task module dimension enum

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

compareSDKVersions(string, string)

Compares SDK versions.

createFile(AssembleAttachment[], string)

Helper function to create a blob from media chunks based on their sequence

decodeAttachment(MediaChunk, string)

Helper function to convert Media chunks into another object type which can be later assemebled Converts base 64 encoded string to byte array and then into an array of blobs

enablePrintCapability()

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

ensureInitialized(string[])
executeDeepLink(string, (status: boolean, reason?: string) => void)

execute deep link API.

generateGUID()

Generates a GUID

generateRegExpFromUrls(string[])
getContext((context: Context) => void)

Retrieves the current context the frame is running in.

getGenericOnCompleteHandler(string)
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.

handleParentMessage(DOMMessageEvent)
initialize(() => void, string[])

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

initializeWithFrameContext(FrameContext, () => void, string[])
isAPISupportedByPlatform(string)

Checks whether the platform has knowledge of this API by doing a comparison on API required version and platform supported version of the SDK

navigateBack((status: boolean, reason?: string) => void)

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

navigateCrossDomain(string, (status: boolean, reason?: string) => void)

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, (status: boolean, reason?: string) => void)

Navigates the Microsoft Teams app to the specified tab instance.

print()

default print handler

processAdditionalValidOrigins(string[])

Processes the valid origins specifuied by the user, de-duplicates and converts them into a regexp which is used later for message source/origin validation

processMessage(DOMMessageEvent)
registerAppButtonClickHandler(() => void)

Registers a handler for clicking the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

registerAppButtonHoverEnterHandler(() => void)

Registers a handler for entering hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

registerAppButtonHoverLeaveHandler(() => void)

Registers a handler for exiting hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

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.

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.

sendMessageEventToChild(string, any[])

Send a custom message object that can be sent to child window, instead of a response message to a child

sendMessageRequestToParent(string, any[])

Send a message to parent. Uses nativeInterface on mobile to communicate with parent context

setFrameContext(FrameContext)
shareDeepLink(DeepLinkParameters)

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

validateGetMediaInputs(string, FileFormat, string)

Returns true if the get Media params are valid and false otherwise

validateSelectMediaInputs(MediaInputs)

Returns true if the mediaInput params are valid and false otherwise

validateViewImagesInput(ImageUri[])

Returns true if the view images param is valid and false otherwise

waitForMessageQueue(Window, () => void)

Function Details

compareSDKVersions(string, string)

Compares SDK versions.

function compareSDKVersions(v1: string, v2: string)

Parameters

v1

string

first version

v2

string

second version returns NaN in case inputs are not in right format -1 if v1 < v2 1 if v1 > v2 0 otherwise For example, compareSDKVersions('1.2', '1.2.0') returns 0 compareSDKVersions('1.2a', '1.2b') returns NaN compareSDKVersions('1.2', '1.3') returns -1 compareSDKVersions('2.0', '1.3.2') returns 1 compareSDKVersions('2.0', 2.0) returns NaN

Returns

number

createFile(AssembleAttachment[], string)

Helper function to create a blob from media chunks based on their sequence

function createFile(assembleAttachment: AssembleAttachment[], mimeType: string)

Parameters

assembleAttachment

AssembleAttachment[]

mimeType

string

Returns

Blob

decodeAttachment(MediaChunk, string)

Helper function to convert Media chunks into another object type which can be later assemebled Converts base 64 encoded string to byte array and then into an array of blobs

function decodeAttachment(attachment: MediaChunk, mimeType: string)

Parameters

attachment
MediaChunk
mimeType

string

Returns

enablePrintCapability()

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

function enablePrintCapability()

ensureInitialized(string[])

function ensureInitialized(expectedFrameContexts: string[])

Parameters

expectedFrameContexts

string[]

execute deep link API.

function executeDeepLink(deepLink: string, onComplete?: (status: boolean, reason?: string) => void)

Parameters

deepLink

string

deep link.

onComplete

(status: boolean, reason?: string) => void

generateGUID()

Generates a GUID

function generateGUID()

Returns

string

generateRegExpFromUrls(string[])

function generateRegExpFromUrls(urls: string[])

Parameters

urls

string[]

Returns

RegExp

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.

getGenericOnCompleteHandler(string)

function getGenericOnCompleteHandler(errorMessage?: string)

Parameters

errorMessage

string

Returns

(success: boolean, reason?: string) => void

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
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
TabInstanceParameters

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

handleParentMessage(DOMMessageEvent)

function handleParentMessage(evt: DOMMessageEvent)

Parameters

evt

DOMMessageEvent

initialize(() => void, string[])

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

function initialize(callback?: () => void, validMessageOrigins?: string[])

Parameters

callback

() => void

Optionally specify a callback to invoke when Teams SDK has successfully initialized

validMessageOrigins

string[]

Optionally specify a list of cross frame message origins. There must have https: protocol otherwise they will be ignored. Example: https://www.example.com

initializeWithFrameContext(FrameContext, () => void, string[])

function initializeWithFrameContext(frameContext: FrameContext, callback?: () => void, validMessageOrigins?: string[])

Parameters

frameContext
FrameContext
callback

() => void

validMessageOrigins

string[]

isAPISupportedByPlatform(string)

Checks whether the platform has knowledge of this API by doing a comparison on API required version and platform supported version of the SDK

function isAPISupportedByPlatform(requiredVersion?: string)

Parameters

requiredVersion

string

SDK version required by the API

Returns

boolean

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

function navigateBack(onComplete?: (status: boolean, reason?: string) => void)

Parameters

onComplete

(status: boolean, reason?: string) => void

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, onComplete?: (status: boolean, reason?: string) => void)

Parameters

url

string

The URL to navigate the frame to.

onComplete

(status: boolean, reason?: string) => void

Navigates the Microsoft Teams app to the specified tab instance.

function navigateToTab(tabInstance: TabInstance, onComplete?: (status: boolean, reason?: string) => void)

Parameters

tabInstance
TabInstance

The tab instance to navigate to.

onComplete

(status: boolean, reason?: string) => void

default print handler

function print()

processAdditionalValidOrigins(string[])

Processes the valid origins specifuied by the user, de-duplicates and converts them into a regexp which is used later for message source/origin validation

function processAdditionalValidOrigins(validMessageOrigins: string[])

Parameters

validMessageOrigins

string[]

processMessage(DOMMessageEvent)

function processMessage(evt: DOMMessageEvent)

Parameters

evt

DOMMessageEvent

registerAppButtonClickHandler(() => void)

Registers a handler for clicking the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonClickHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when the personal app button is clicked in the app bar.

registerAppButtonHoverEnterHandler(() => void)

Registers a handler for entering hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonHoverEnterHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when entering hover of the personal app button in the app bar.

registerAppButtonHoverLeaveHandler(() => void)

Registers a handler for exiting hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonHoverLeaveHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when exiting hover of the personal app button in the app bar.

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.

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.

sendMessageEventToChild(string, any[])

Send a custom message object that can be sent to child window, instead of a response message to a child

function sendMessageEventToChild(actionName: string, args?: any[])

Parameters

actionName

string

args

any[]

sendMessageRequestToParent(string, any[])

Send a message to parent. Uses nativeInterface on mobile to communicate with parent context

function sendMessageRequestToParent(actionName: string, args?: any[])

Parameters

actionName

string

args

any[]

Returns

number

setFrameContext(FrameContext)

function setFrameContext(frameContext: FrameContext)

Parameters

frameContext
FrameContext

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
DeepLinkParameters

ID and label for the link and fallback URL.

validateGetMediaInputs(string, FileFormat, string)

Returns true if the get Media params are valid and false otherwise

function validateGetMediaInputs(mimeType: string, format: FileFormat, content: string)

Parameters

mimeType

string

format
FileFormat
content

string

Returns

boolean

validateSelectMediaInputs(MediaInputs)

Returns true if the mediaInput params are valid and false otherwise

function validateSelectMediaInputs(mediaInputs: MediaInputs)

Parameters

mediaInputs
MediaInputs

Returns

boolean

validateViewImagesInput(ImageUri[])

Returns true if the view images param is valid and false otherwise

function validateViewImagesInput(uriList: ImageUri[])

Parameters

uriList

ImageUri[]

Returns

boolean

waitForMessageQueue(Window, () => void)

function waitForMessageQueue(targetWindow: Window, callback: () => void)

Parameters

targetWindow

Window

callback

() => void