Skip to content

Latest commit

 

History

History
 
 
page_type description products languages extensions urlFragment
sample
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.
office-teams
office
office-365
nodejs
contentType createdDate
samples
27-07-2021 16:32:33
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. (Sideloading 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.

  • Teams Toolkit for VS Code or TeamsFx CLI

Run the app (Using Teams Toolkit for Visual Studio Code)

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

  1. Ensure you have downloaded and installed Visual Studio Code
  2. Install the Teams 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 (sideloading), Teams 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. Register a new application in the Microsoft Entra ID – App Registrations portal.

  2. Setup NGROK

  1. 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

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 [email protected] with any additional questions or comments.

Further reading