public async void OnAppleSignInRequest() { try { IAppleSignInService appleSignInService = DependencyService.Get <IAppleSignInService>(); var account = await appleSignInService.SignInAsync(); if (account != null) { Preferences.Set(App.LoggedInKey, true); await SecureStorage.SetAsync(App.AppleUserIdKey, account.UserId); string email = ""; if (account.Email != null) { await SecureStorage.SetAsync(account.UserId, account.Email); Application.Current.Properties[account.UserId.ToString()] = account.Email; } else { email = await SecureStorage.GetAsync(account.UserId); if (email == null) { if (Application.Current.Properties.ContainsKey(account.UserId.ToString())) { email = (string)Application.Current.Properties[account.UserId.ToString()]; } else { email = ""; } } account.Email = email; } UserDialogs.Instance.ShowLoading("We are processing your request..."); var authenticationStatus = await client.UserVerification(null, account, "APPLE"); if (authenticationStatus == "EMAIL WAS NOT FOUND") { account.Email = "*****@*****.**"; account.UserId = ""; account.Name = ""; account.RealUserStatus = ""; account.Token = ""; authenticationStatus = await client.UserVerification(null, account, "APPLE"); } ProcessRequest(authenticationStatus); } } catch (Exception errorSignInRequest) { await Application.Current.MainPage.DisplayAlert("Error", errorSignInRequest.Message, "OK"); } }
public LoginViewModel() { Console.WriteLine("in LoginViewModel, entered LoginViewModel()"); appleSignInService = DependencyService.Get <IAppleSignInService>(); Console.WriteLine("after appleSignInService reached"); SignInWithAppleCommand = new Command(OnAppleSignInRequest); Console.WriteLine("after SignInWithAppleCommand reached"); }
// This function checks if the user was able to succesfully login to their Apple account. Once the // user autheticates throught Apple, we validate their credentials in our system. async void OnAppleSignInRequest() { try { IAppleSignInService appleSignInService = DependencyService.Get <IAppleSignInService>(); var account = await appleSignInService.SignInAsync(); if (account != null) { Preferences.Set(App.LoggedInKey, true); await SecureStorage.SetAsync(App.AppleUserIdKey, account.UserId); string email = ""; if (account.Email != null) { await SecureStorage.SetAsync(account.UserId, account.Email); Application.Current.Properties[account.UserId.ToString()] = account.Email; } else { email = await SecureStorage.GetAsync(account.UserId); if (email == null) { if (Application.Current.Properties.ContainsKey(account.UserId.ToString())) { email = (string)Application.Current.Properties[account.UserId.ToString()]; } else { email = ""; } } account.Email = email; } var client = new SignIn(); UserDialogs.Instance.ShowLoading("Retrieving your JD account..."); var status = await client.VerifyUserCredentials("", "", null, account, "APPLE"); RedirectUserBasedOnVerification(status, direction); } } catch (Exception errorAppleSignInRequest) { //var client = new Diagnostic(); //client.parseException(errorAppleSignInRequest.ToString(), user); Debug.WriteLine("ERROR IN 'OnAppleSignInRequest': " + errorAppleSignInRequest.Message); } }
public AppleLogIn() { appleSignInService = DependencyService.Get <IAppleSignInService>(); SignInWithAppleCommand = new Command(OnAppleSignInRequest); if (Device.RuntimePlatform == Device.iOS) { deviceId = Preferences.Get("guid", null); if (deviceId != null) { Debug.WriteLine("This is the iOS GUID from Direct Sign Up: " + deviceId); } } }
public LoginViewModel() { appleSignInService = DependencyService.Get <IAppleSignInService>(); SignInWithAppleCommand = new Command(OnAppleSignInRequest); }