Skip to content

Latest commit

 

History

History
 
 

README.md

page_type sample
description This sample app for Microsoft Teams demonstrates how to handle device permissions, including audio, video, and geolocation, within a tab interface. It provides insights into device permission usage across desktop and mobile views, allowing developers to enhance user interactions effectively.
products
office-teams
office
office-365
languages
nodejs
extensions
contentType createdDate
samples
27-07-2021 16:32:33
urlFragment officedev-microsoft-teams-samples-tab-device-permissions-nodejs

Tab Device Permission

Discover this Microsoft Teams tab sample app that illustrates the management of device permissions for audio, video, and geolocation. With comprehensive setup instructions and support for both desktop and mobile views, this app empowers developers to create interactive experiences by leveraging device capabilities. tab device permissions.

It also shows Device permissions for the browser. Please refer Device permissions for browser for more information.

Currently only capture image is supported in Teams Desktop client.

Included Features

  • Tabs
  • Device Permissions (geolocation, media)

Interaction with app - Desktop View

Tab Device PermissionsGif

Interaction with app - Mobile View

Tab Device PermissionsGif Mobile

Try it yourself - experience the App in your Microsoft Teams client

Please find below demo manifest which is deployed on Microsoft Azure and you can try it yourself by uploading the app package (.zip file link below) to your teams and/or as a personal app. (Uploading must be enabled for your tenant, see steps here).

Tab Device Permission: Manifest

Prerequisites

To test locally, NodeJS must be installed on your development machine (version 16.14.2 or higher).

```bash
# determine node version
node --version
```
  • dev tunnel or ngrok or equivalent tunneling solution If you are using Ngrok to test locally, you'll need Ngrok installed on your development machine. Make sure you've downloaded and installed Ngrok on your local machine. ngrok will tunnel requests from the Internet to your local computer and terminate the SSL connection from Teams.

  • M365 developer account or access to a Teams account with the appropriate permissions to install an app.

  • Microsoft 365 Agents Toolkit for VS Code or TeamsFx CLI

Run the app (Using Microsoft 365 Agents Toolkit for Visual Studio Code)

The simplest way to run this sample in Teams is to use Microsoft 365 Agents Toolkit for Visual Studio Code.

  1. Ensure you have downloaded and installed Visual Studio Code
  2. Install the Microsoft 365 Agents Toolkit extension
  3. Select File > Open Folder in VS Code and choose this samples directory from the repo
  4. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
  5. Select Debug > Start Debugging or F5 to run the app in a Teams web client.
  6. In the browser that launches, select the Add button to install the app to Teams.

If you do not have permission to upload custom apps (uploading), Microsoft 365 Agents Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

Setup

NOTE: The free ngrok plan will generate a new URL every time you run it, which requires you to update your Azure AD registration, the Teams app manifest, and the project configuration. A paid account with a permanent ngrok URL is recommended.

  1. App Registration

Register your application with Azure AD

  1. Register a new application in the Microsoft Entra ID – App Registrations portal.
  2. Select New Registration and on the register an application page, set following values:
    • Set name to your app name.
    • Choose the supported account types (any account type will work)
    • Leave Redirect URI empty.
    • Choose Register.
  3. On the overview page, copy and save the Application (client) ID, Directory (tenant) ID. You'll need those later when updating your Teams application manifest and in the appsettings.json.
  4. Navigate to API Permissions, and make sure to add the follow permissions:
    • Select Add a permission
    • Select Microsoft Graph -> Delegated permissions.
    • User.Read (enabled by default)
    • Click on Add permissions. Please make sure to grant the admin consent for the required permissions.
  1. Setup NGROK

  2. Run ngrok - point to port 3000

    ngrok http 3000 --host-header="localhost:3000"

    Alternatively, you can also use the dev tunnels. Please follow Create and host a dev tunnel and host the tunnel with anonymous user access command as shown below:

    devtunnel host -p 3000 --allow-anonymous
  1. Setup for code
  • Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  • In a terminal, navigate to samples/tab-device-permissions/nodejs

  • Install modules

    npm install
  • Start the bot

    npm start
  1. Setup Manifest for Teams
  • This step is specific to Teams.
    • Edit the manifest.json contained in the ./appManifest folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) everywhere you see the place holder string {{Microsoft-App-Id}} (depending on the scenario the Microsoft App Id may occur multiple times in the manifest.json)
    • Edit the manifest.json for validDomains and replace {{domain-name}} with base Url of your domain. E.g. if you are using ngrok it would be https://1234.ngrok-free.app then your domain-name will be 1234.ngrok-free.app and if you are using dev tunnels then your domain will be like: 12345.devtunnels.ms.
    • Zip up the contents of the appManifest folder to create a manifest.zip (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)

Running the sample - Desktop View

Install app:

Install App

Grant Permissions for Sample

  • Enable Microphone, Camera, and Location for Tab Sample

  • You can enable the permissions in either of the following ways: 1.By clicking the lock icon in the browser address bar 2.From the tab's site settings.

  • After updating the settings, please reload the page and test the sample.

Tab View Settings

Tab View Settings

Browser Settings

Device permission tab: (Web View)

desktopHome

Device permission tab: (Desktop View)

desktopHome

Tab device permission:

deviceBrowser

Running the sample - Mobile View

Tab device permission(Capture Image and Media):

mainTab1

Tab device permission(Scan Barcode):

mainTab2

Tab device permission(People Picker and Get Location):

mainTab3

Device permission popup:

allowPermission

Similary, you can try out for other features.

Important

Please take a look at notes section in Device Permissions documentation as not all devices support these permissions.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Further reading