From 2620d91331af3ef444425b477d00fd3bf4514237 Mon Sep 17 00:00:00 2001 From: Morgan - 6 Freedom Date: Sat, 27 Jan 2024 14:51:34 +0100 Subject: [PATCH] fix authentication --- Assets/Scripts/FirebaseInitializer.cs | 33 ++++++++++++++++++++-- Assets/Scripts/FirebaseInitializer.cs.meta | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/FirebaseInitializer.cs b/Assets/Scripts/FirebaseInitializer.cs index 5f0247c..afeeed5 100644 --- a/Assets/Scripts/FirebaseInitializer.cs +++ b/Assets/Scripts/FirebaseInitializer.cs @@ -2,6 +2,7 @@ using System.Collections; using UnityEngine; using System; +using UnityEngine.Android; public class FirebaseInitializer : MonoBehaviour { @@ -14,8 +15,10 @@ void Awake() } // Start is called before the first frame update - IEnumerable Start() + void Start() { + AskForCameraAuthorizationForAndroid(); + FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; @@ -33,8 +36,6 @@ IEnumerable Start() Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}"); } }); - - yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); } // Update is called once per frame @@ -61,4 +62,30 @@ void Authenticate() onFirebaseReady?.Invoke(); }); } + + private void AskForCameraAuthorizationForAndroid() + { + if (Permission.HasUserAuthorizedPermission(Permission.Microphone)) + { + // The user authorized use of the microphone. + } + else + { + bool useCallbacks = false; + if (!useCallbacks) + { + // We do not have permission to use the microphone. + // Ask for permission or proceed without the functionality enabled. + Permission.RequestUserPermission(Permission.Microphone); + } + else + { + var callbacks = new PermissionCallbacks(); + //callbacks.PermissionDenied += PermissionCallbacks_PermissionDenied; + //callbacks.PermissionGranted += PermissionCallbacks_PermissionGranted; + //callbacks.PermissionDeniedAndDontAskAgain += PermissionCallbacks_PermissionDeniedAndDontAskAgain; + Permission.RequestUserPermission(Permission.Microphone, callbacks); + } + } + } } diff --git a/Assets/Scripts/FirebaseInitializer.cs.meta b/Assets/Scripts/FirebaseInitializer.cs.meta index 15b1e53..b352e68 100644 --- a/Assets/Scripts/FirebaseInitializer.cs.meta +++ b/Assets/Scripts/FirebaseInitializer.cs.meta @@ -4,7 +4,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -50 icon: {instanceID: 0} userData: assetBundleName: