OfficeDev / office-js-docs-reference

Microsoft Office JavaScript API Reference
https://learn.microsoft.com/javascript/api/overview
MIT License
105 stars 63 forks source link

Office.DevicePermissionType.microphone is undefined #1939

Closed YesLetsGo closed 4 weeks ago

YesLetsGo commented 1 month ago

While executing the method:

 // Request permission from a user to access their camera, geolocation, and microphone.
  if (Office.context.mailbox.diagnostics.hostName === "OutlookWebApp") {
    const deviceCapabilities = [
        Office.DevicePermissionType.microphone
    ];

    Office.devicePermission.requestPermissionsAsync(deviceCapabilities, (asyncResult) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.log (asyncResult.error.message);
            return;
        }

        if (asyncResult.value) {
            console.log("Permission granted.");

            // Do something when permission is granted.
        } else {
            console.log("Permission denied.");

            // Do something when permission is denied.
        }
    });
  }

The browser displays an error TypeError: Cannot read properties of undefined (reading 'microphone') in line Office.DevicePermissionType.microphone.

samantharamon commented 1 month ago

Hi @YesLetsGo,

The permission dialog appears when I test the snippet you provided. I tested it in Edge. When you get a chance, could you clear your browser cache and try running the snippet again? Does the device on which you're testing also have a connected or built-in microphone?

microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

microsoft-github-policy-service[bot] commented 4 weeks ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.