private void CheckUserAvailability() { try { var userRef = SessionManager.UserRef.Child(SessionManager.UserId); userRef.AddValueEventListener(new SingleValueListener( onDataChange: (s) => { if (!s.Exists()) { GotoProfile(); } else { var firstname = s.Child("profile").Child("fname") == null ? "" : s.Child("profile").Child("fname").Value.ToString(); GotoMain(firstname); } }, onCancelled: (e) => { })); } catch (Exception e) { OnboardingActivity.ShowError(e.Source, e.Message); } }
private void VerifyCode(string code) { OnboardingActivity.ShowLoader(); PhoneAuthCredential cred = PhoneAuthProvider.GetCredential(verificationId, code); auth.SignInWithCredential(cred) .AddOnCompleteListener(new OncompleteListener( onComplete: (t) => { try { switch (t.IsSuccessful) { case false: throw t.Exception; default: CheckUserAvailability(); break; } } catch (FirebaseAuthInvalidCredentialsException fiace) { OnboardingActivity.DismissLoader(); OnboardingActivity.ShowError(fiace.Source, fiace.Message); } catch (FirebaseTooManyRequestsException ftmre) { OnboardingActivity.DismissLoader(); OnboardingActivity.ShowError(ftmre.Source, ftmre.Message); } catch (FirebaseAuthInvalidUserException fiue) { OnboardingActivity.DismissLoader(); OnboardingActivity.ShowError(fiue.Source, fiue.Message); } catch (FirebaseNetworkException) { OnboardingActivity.DismissLoader(); OnboardingActivity.ShowNoNetDialog(false); } catch (Exception e) { OnboardingActivity.DismissLoader(); OnboardingActivity.ShowError(e.Source, e.Message); } })); }
private void SendVerificationCode() { auth = SessionManager.GetFirebaseAuth(); PhoneAuthProvider.GetInstance(auth) .VerifyPhoneNumber(phone, 30, TimeUnit.Seconds, Activity, new PhoneVerificationCallbacks( onVerificationCompleted: (cred) => { var code = cred.SmsCode; if (string.IsNullOrEmpty(code)) { return; } otpView.Value = code; VerifyCode(code); }, onVerificationFailed: (e) => { try { resendBtn.Enabled = false; cdTimer.Cancel(); throw e; } catch (FirebaseNetworkException) { OnboardingActivity.ShowNoNetDialog(false); } catch (FirebaseTooManyRequestsException ftmre) { OnboardingActivity.ShowError(ftmre.Source, ftmre.Message); } catch (FirebaseAuthInvalidCredentialsException faice) { OnboardingActivity.ShowError(faice.Source, faice.Message); } catch (FirebaseAuthInvalidUserException fiue) { OnboardingActivity.ShowError(fiue.Source, fiue.Message); } catch (Exception ex) { OnboardingActivity.ShowError(ex.Source, ex.Message); } }, onCodeSent: (code, token) => { verificationId = code; })); }
public void OnError(FacebookException error) { OnboardingActivity.ShowError(error.Source, error.Message); }
public void OnCancel() { OnboardingActivity.ShowError("Login canceled", "You canceled the login operation"); }
private async void SaveToDb() { try { var profileRef = SessionManager.GetFireDB().GetReference($"users/{SessionManager.UserId}/profile"); var userMap = new HashMap(); var stream = new System.IO.MemoryStream(); var bitmap = MediaStore.Images.Media.GetBitmap(Context.ContentResolver, img_uri); await bitmap.CompressAsync(Bitmap.CompressFormat.Webp, 90, stream); var imgArray = stream.ToArray(); var imageRef = FirebaseStorage.Instance.GetReference($"profileImages/{SessionManager.UserId}"); imageRef.PutBytes(imgArray).ContinueWithTask(new ContinuationTask( then: t => { if (!t.IsSuccessful) { throw t.Exception; } })).AddOnCompleteListener(new OncompleteListener( onComplete: t => { if (!t.IsSuccessful) { throw t.Exception; } userMap.Put(Constants.SNAPSHOT_FNAME, fullnameEt.EditText.Text); userMap.Put(Constants.SNAPSHOT_EMAIL, emailEt.EditText.Text); userMap.Put(Constants.SNAPSHOT_GENDER, (int)userGender); userMap.Put(Constants.SNAPSHOT_PHONE, SessionManager.GetFirebaseAuth().CurrentUser.PhoneNumber); userMap.Put(Constants.SNAPSHOT_PHOTO_URL, t.Result.ToString()); profileRef.SetValue(userMap).AddOnCompleteListener(new OncompleteListener( onComplete: task => { try { if (!task.IsSuccessful) { throw task.Exception; } GetSmsFragment.SetStatus("set_partner"); ParentFragmentManager.BeginTransaction() .Replace(Resource.Id.frag_container, new PartnerFragment()) .CommitAllowingStateLoss(); } catch (DatabaseException de) { OnboardingActivity.ShowError("Database Exception", de.Message); } })); profileRef.KeepSynced(true); })); } catch (DatabaseException fde) { OnboardingActivity.ShowError("Database Exception", fde.Message); } catch (FirebaseNetworkException) { OnboardingActivity.ShowNoNetDialog(false); } catch (StorageException se) { OnboardingActivity.ShowError("Storage Exception", se.Message); } catch (Exception ex) { OnboardingActivity.ShowError("Exception", ex.Message); } }