Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

What to do when the camera access is denied?

Discussion in 'AR' started by luispedrofonseca, Dec 11, 2018.

  1. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    904
    Hi, I just realized there doesn't seem to exist any API to invoke the camera access dialogue in case the user rejects it the first time it appears.

    Once the user rejects the camera access, the session fires a "ARSessionFailedEvent" with the string "Camera access not authorized". However, this string seems to be localized which means you can't even rely on it to know if the user rejected camera access because the string will be different in another language.

    All the examples I've seen don't take this into consideration and always assume the user accepts camera access at first try.

    @jimmya Can you confirm if it's possible to detect this and act accordingly?

    Any hints anyone?
     
    Last edited: Dec 12, 2018
  2. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    904
    For anyone wondering the same, you can't, apparently, re-ask the user if the use of the camera is allowed.

    This means that if the user denies it the first time you ask, from then on you'll need to warn the user that the camera access has been denied and it has to be re-enabled at the iOS Settings app, under Privacy > Camera.

    To know this you'll need to use an external library since this functionality is not part of ARKit. This one works great and it's very lightweight: https://github.com/neogeek/Unity-iOS-Bridge-Test/blob/master/Assets/Scripts/TestBridge.cs#L9
     
    hungrybelome likes this.
  3. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65
    But how would one know that the user has denied access for camera?
     
  4. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    904
    @karsnen Did you read my post above?
     
  6. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65