fix authentication

This commit is contained in:
Morgan - 6 Freedom 2024-01-27 14:51:34 +01:00
parent ea295d0325
commit 2620d91331
2 changed files with 31 additions and 4 deletions

View File

@ -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);
}
}
}
}

View File

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: -50
icon: {instanceID: 0}
userData:
assetBundleName: