Ejemplo n.º 1
0
        public Task <IAuthResult> LinkWithProviderAsync(IFederatedAuthProvider federatedAuthProvider)
        {
            var tcs = new TaskCompletionSource <IAuthResult>();

            federatedAuthProvider.ToNative().Completion(FirebaseAuth.LinkWithProviderAuthUIDelegate, (credential, error) =>
            {
                if (error != null)
                {
                    tcs.SetException(ExceptionMapper.Map(error));
                }
                else
                {
                    _user.Link(credential, (result, error) =>
                    {
                        if (error != null)
                        {
                            tcs.SetException(ExceptionMapper.Map(error));
                        }
                        else
                        {
                            tcs.SetResult(new AuthResultWrapper(result));
                        }
                    });
                }
            });

            return(tcs.Task);
        }
Ejemplo n.º 2
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);
            }
        }