Navigator.Permissions在Safari 15.5中不确定(用于摄像机权限)

发布于 2025-02-10 02:12:38 字数 811 浏览 1 评论 0 原文

我有一个使用相机设备的应用程序。

我使用getCamerapermession()方法来获取用户访问用户的许可。它适用于Safari更新版本,但不适用于15.5版。

    public getCameraPermission = (): Promise<CameraPermissionState> => new Promise((resolve) => {
    if ((navigator as any).permissions) {
        var gg = (navigator as any).permissions.query({ name: 'camera' });
        gg.then(({ state }: { state: CameraPermissionState }) => resolve(state))
            .catch(() => resolve(CameraPermissionState.UNKNOWN));
    } else {
        return resolve(CameraPermissionState.UNKNOWN);
    }
})

(导航器作为任何)。如果我从Safari 15.5(带有Mac)运行它,则返回未定义,然后我无法正确检测到Camerapermission。

我也没有移动野生动物园的问题。

我检查了stackoverflow中的相关主题,但是它们要么是地理位置,要么没有工作。

*我可以访问摄像机 *Safari提示摄像机使用用户权限,即使用户接受我仍然获得了权限未定义的

任何想法,我该如何解决这个问题?

I have an application which uses camera device.

I use getCameraPermission() method to get the permission from user for camera access. It works for Safari newer versions but not 15.5 version.

    public getCameraPermission = (): Promise<CameraPermissionState> => new Promise((resolve) => {
    if ((navigator as any).permissions) {
        var gg = (navigator as any).permissions.query({ name: 'camera' });
        gg.then(({ state }: { state: CameraPermissionState }) => resolve(state))
            .catch(() => resolve(CameraPermissionState.UNKNOWN));
    } else {
        return resolve(CameraPermissionState.UNKNOWN);
    }
})

(navigator as any).permissions return undefined if i run it from Safari 15.5 (with Mac) and then i can not detect the camerapermission correctly.

I also dont have an issue for mobile safari.

I checked the relevant subjects in stackoverflow however they were either for GeoLocation or they did not work.

*I can access to cameras
*Safari prompts camera using permission to user, even if user accepts i still get permissions undefined

Any ideas how can i workaround that problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧幽蓝 2025-02-17 02:12:38

对于Safari而言,权限API仍在技术预览中:

source

因此,您不能在较旧版本上使用它。

caniuse 页面确实列出了 polyfill ,但是我不喜欢知道在野生动物园中是否有效15.5

The permissions API is still in technical preview, for Safari:

enter image description here
(source)

As such, you can't use it on older versions.

That caniuse page does list a polyfill, but I don't know if and how well that'd work on Safari 15.5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文