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.

Permission.RequestUserPermission Freeze my game every time. Why?

Discussion in 'Getting Started' started by Sparticus, Dec 31, 2022.

  1. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    147
    Hey all,

    I have the following code :

    Code (CSharp):
    1. if (!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS")) {
    2.             Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS");
    3. }
    When I run it (ie. called when a button was pressed).... then my game freezes. I can see the framerate basically drops to 1 at best. I can tell it has not crashed the game because if I put a Debug.Log inside an Update, I see some log messages.

    Any idea why?

    (I have confirmed I am not doing anything stupid like calling it many times in a loop, etc)