Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to request a run time permission when I need?

Discussion in 'Android' started by skyvuhieutran, Jun 4, 2019.

  1. skyvuhieutran

    skyvuhieutran

    Joined:
    May 28, 2019
    Posts:
    10
    Hi all.
    I am working AR. Currently, when user install my first app. It asks user grant permission camera. If they allow it, my game work perfectly, but if they deny, it will crash when user assesses AR feature.
    So I need to show dialog that show question permission camera again. And show again when they continue deny permission.
    (Bolt platform Android and iOS)
    I has searched issue many times, I found answer on Unity document 2019. But my version is 2018.2.20.
    Can you help me with issue or give me somes clues. Thanks a lot!
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    Android runtime permissions are supported since Unity 2018.3: https://docs.unity3d.com/2018.3/Documentation/Manual/android-RequestingPermissions.html
    If you can't upgrade to 2018.3, you can try to use this plugin: https://github.com/Over17/UnityAndroidPermissions
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Another trick might be to attempt to use the camera, and if denied (or if you can catch an exception), you can take action. This implies of course that there isn't something going amiss before Start() or Awake()