Bypass Permissions Request

Hi there,

Is there a function I can call to check if a user has previously granted access to their camera for a UAR experience? I understand there is the ZapparThree.permissionRequest() function - but I would like to check if the user has visited the experience/enabled permissions before without having to press any buttons, and bypass my permissions request UI if they have.

Many thanks!

Well there is the Permissions API, but I wouldn’t rely on it since Safari doesn’t support it yet. You can store a variable in localStorage but that is not a good idea because the user can revoke permissions at any time and your variable would have the wrong state. Third option and it’s what I use, is to attempt to access the camera without requesting permission. If you get an error, catch it and request permission. If not, all good.

Thanks @marks for your help.

1 Like

Is there any way to check if the camera is active? I would use camera.start() but it automatically brings up the device’s permissions request which I don’t want to do. I also can’t find anything within the camera gameobject that would help me distinguish if it’s active or not.

Thank you!

Check the enabled property of the MediaStreamTrack. You can access this by using the MediaStreamGetTracks method of the MediaStream returned by MediaDevices.getUserMedia(), which is the method used to access the camera.

You can find a detailed tutorial on how to access the webcam here.