Request Camera Permission on iOS in Unity at Runtime

4.6k Views Asked by At

Our application built in Unity uses ARKit/FaceTracking on iOS. We would like to request the Camera Permission at runtime immediately before it is used - and not on application startup.

What should happen
I use Application.RequestUserAuthorization immediately before the camera is used. According to the documentation this is supposed to trigger the permission request.

What actually happens When the compiled application is started on an iOS device, the permission is requested straight away. If the permission is denied, it appears that all further calls to Application.RequestUserAuthorization instantly return (without triggering another request) and the permission remains denied.

I assume that Application.RequestUserAuthorization would work as expected, if the App wouldn't already request the permission on startup - but we do not actively trigger this request in our code. So I guess here is my

Question: How do I get rid of the initial Camera permission request?

What could have caused it in the first place? For all I know, it shouldn't be the plist-string for the camera permission. Is it already just the imports of the ArKit libraries? If not, how can I even begin to look for a cause?

Link to related question in unity forums

2

There are 2 best solutions below

0
On

based on my experience, ARKit/ARCore requests permission when the ARSession is enabled. so at runtime if your ARSession is disabled (i.e. on inspector before you build) the permission pop-up only appears when you enable the ARSession Object (i.e. its time to use the session)

0
On

According to this page, it seems like Apple is forcing this pop-up when you use ARKit.