Exemplo n.º 1
0
        public async Task <IAuthResult> LinkWithProviderAsync(IFederatedAuthProvider federatedAuthProvider)
        {
            var activity = CrossCurrentActivity.Current.Activity ?? throw new NullReferenceException("current activity is null");

            try
            {
                Firebase.Auth.IAuthResult result;

                var auth = Firebase.Auth.FirebaseAuth.GetInstance(_user.Zzc());
                var pendingResultTask = auth.GetPendingAuthResult();

                if (pendingResultTask != null)
                {
                    result = await pendingResultTask.AsAsync <Firebase.Auth.IAuthResult>().ConfigureAwait(false);
                }
                else
                {
                    result = await _user.StartActivityForLinkWithProvider(activity, federatedAuthProvider.ToNative()).AsAsync <Firebase.Auth.IAuthResult>()
                             .ConfigureAwait(false);
                }

                return(new AuthResultWrapper(result));
            }
            catch (FirebaseException e)
            {
                throw ExceptionMapper.Map(e);
            }
        }