public override async void ViewAppeared()
        {
            base.ViewAppeared();

            if (_isInitialAppearance)
            {
                _isInitialAppearance = false;
                // Attempt to authenticate silently - with a previously stored token
                var hasToken = await AuthService.AcquireTokenSilently();

                if (hasToken)
                {
                    // Authenticated, so check for required permissions
                    await HandleAppPermissions();
                }
                else
                {
                    // Hasn't authenticated
                    // Subscribe to the Authentication OnAuthChanged event (fired when authentication succeeds)
                    AuthService.OnAuthChanged += HandleOnAuthChanged;
                    // Trigger login screen
                    OnDisplayLogin?.Invoke();
                }
            }
        }
 async void HandleOnAuthChanged(object sender, AuthChangedEventArgs e)
 {
     if (e.IsLoggedIn)
     {
         await HandleAppPermissions();
     }
     else
     {
         OnDisplayLogin?.Invoke();
     }
 }
 // Called when the Authentication OnAuthChanged event fires - when authentication with credentials succeeds
 async void HandleOnAuthChanged(object sender, AuthChangedEventArgs e)
 {
     if (e.IsLoggedIn)
     {
         // Authenticated, so check for required permissions
         await HandleAppPermissions();
     }
     else
     {
         // Not authenticated, so update login screen
         OnDisplayLogin?.Invoke();
     }
 }
        public override async void ViewAppeared()
        {
            base.ViewAppeared();

            if (isInitialAppearance)
            {
                isInitialAppearance = false;
                var hasToken = await AuthService.AcquireTokenSilently();

                AuthService.OnAuthChanged += HandleOnAuthChanged;
                if (hasToken)
                {
                    await HandleAppPermissions();
                }
                else
                {
                    OnDisplayLogin?.Invoke();
                }
            }
        }