티스토리 뷰
728x90
반응형
Xamarin.Android에 이어서..
using System;
using System.Threading.Tasks;
using ######..iOS.Services;
using ######.Models.FirebasePageModel;
using ######.Services.Account;
using Firebase.Auth;
using Foundation;
using Xamarin.Forms;
[assembly: Dependency(typeof(AccountService))]
namespace ######.iOS.Services
{
public class AccountService : IAccountService
{
public AccountService()
{
}
public Task<bool> SendOtpCodeAsync(string phoneNumber)
{
_phoneAuthTcs = new TaskCompletionSource<bool>();
PhoneAuthProvider.DefaultInstance.VerifyPhoneNumber(
phoneNumber,
null,
new VerificationResultHandler(OnVerificaitonResult));
return _phoneAuthTcs.Task;
}
private string _verificationId;
private void OnVerificaitonResult(string verificationId, NSError error)
{
if (error != null)
{
_phoneAuthTcs?.TrySetResult(false);
return;
}
_verificationId = verificationId;
_phoneAuthTcs?.TrySetResult(true);
}
public Task<bool> VerifyOtpCodeAsync(string code)
{
var tcs = new TaskCompletionSource<bool>();
var credential = PhoneAuthProvider.DefaultInstance.GetCredential(_verificationId, code);
Auth.DefaultInstance.SignInWithCredentialAsync(credential)
.ContinueWith((task) => OnAuthCompleted(task, tcs));
return tcs.Task;
}
private TaskCompletionSource<bool> _phoneAuthTcs;
private void OnAuthCompeleted(Task task, TaskCompletionSource<bool> tcs)
{
if (task.IsCanceled || task.IsFaulted)
{
tcs.SetResult(false);
return;
}
tcs.SetResult(true);
}
private void OnAuthCompleted(Task task, TaskCompletionSource<bool> tcs)
{
if (task.IsCanceled || task.IsFaulted)
{
tcs.SetResult(false);
return;
}
tcs.SetResult(true);
}
}
}
반응형
'Xamarin' 카테고리의 다른 글
iOS UiView CGRect Error (0) | 2021.05.03 |
---|---|
Xamarin.Android reCAPTCHA (0) | 2021.04.13 |
Xamarin.Andorid Firebase Phone Auth, SMS OTP Send , User Add (1) | 2021.04.13 |
FireStore 설치후 Xamarin.Android.D8.targets(79,5): error MSB6006: "java.exe" exited with code 1. (0) | 2021.04.09 |
Xamarin.Forms Android PhoneAuthProvider.Instance.VerifyPhoneNumber deprecated Resolve (0) | 2021.04.08 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Xamarin.Forms
- Xamarin Firebase Phone Auth
- Linux SSH Multi Computer Join
- WPF Textbox
- FileStream Add Byte
- GetCellContent CheckBox Value
- Xamarin reCAPTCHA
- SkiaSharp
- C# LINQ Left join
- Xamarin.Ios Firebase Phone SMS OTP Send
- Entry '' has empty native path
- Xamarin.Ios Firebase Phone Auth
- Xamarin SMS OTP Send
- 연산자 뒤에 피연산자가 없습니다.
- Microcharts
- Embeded 한글Font적용
- ClickOnce 인증서 인증기간 변경
- 서버 수준의 URN 필터
- WPF Scrollviewer in ScrollViwer
- Xamarin.Ios Firebase Phone User Add
- Label Text LineBreak in Xaml
- ssl_client_socket_impl.cc
- 암호 마스터키
- c# Encrypt / Decrypt
- Xamarin Firebase Phone User Add
- WPF Datagrid Cell Value Change
- WPF Excel Export Microsoft.Office.Interop 성능향상(열 기준으로 복사)
- Windows IIS FTP 디렉토리 목록 오류
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함