private async void LogoutExecute() { var confirm = await TLMessageDialog.ShowAsync("Are you sure you want to logout?", "Unigram", "OK", "Cancel"); if (confirm != ContentDialogResult.Primary) { return; } await _pushService.UnregisterAsync(); var response = await ProtoService.LogOutAsync(); if (response.IsSucceeded) { await _contactsService.UnsyncContactsAsync(); SettingsHelper.IsAuthorized = false; SettingsHelper.UserId = 0; ProtoService.ClearQueue(); _updatesService.ClearState(); _stickersService.Cleanup(); CacheService.ClearAsync(); CacheService.ClearConfigImportAsync(); await TLMessageDialog.ShowAsync("The app will be closed. Relaunch it to login again.", "Unigram", "OK"); App.Current.Exit(); } else { } }
private async void LogoutExecute() { var confirm = await TLMessageDialog.ShowAsync(Strings.Android.AreYouSureLogout, Strings.Android.AppName, Strings.Android.OK, Strings.Android.Cancel); if (confirm != ContentDialogResult.Primary) { return; } await _pushService.UnregisterAsync(); var response = await ProtoService.LogOutAsync(); if (response.IsSucceeded) { await _contactsService.RemoveAsync(); SettingsHelper.IsAuthorized = false; SettingsHelper.UserId = 0; //ProtoService.ClearQueue(); _updatesService.ClearState(); _stickersService.Cleanup(); CacheService.ClearAsync(); CacheService.ClearConfigImportAsync(); App.Current.Exit(); } else { } }
public void Confirm() { if (_changePhoneNumber) { ConfirmChangePhoneNumber(); return; } IsWorking = true; StateService.PhoneCode = new TLString(Code); #if LOG_REGISTRATION TLUtils.WriteLog("auth.signIn"); #endif MTProtoService.SignInAsync( StateService.PhoneNumber, StateService.PhoneCodeHash, StateService.PhoneCode, auth => BeginOnUIThread(() => { #if LOG_REGISTRATION TLUtils.WriteLog("auth.signIn result " + auth); TLUtils.WriteLog("TLUtils.IsLogEnabled=false"); #endif TLUtils.IsLogEnabled = false; TLUtils.LogItems.Clear(); TimeCounterString = string.Empty; HelpVisibility = Visibility.Collapsed; _callTimer.Stop(); var result = MessageBox.Show( AppResources.ConfirmPushMessage, AppResources.ConfirmPushTitle, MessageBoxButton.OKCancel); if (result != MessageBoxResult.OK) { Notifications.Disable(); } else { Notifications.Enable(); } UpdateNotificationsAsync(MTProtoService, StateService); MTProtoService.SetInitState(); CacheService.ClearConfigImportAsync(); //_updatesService.SetCurrentUser(auth.User); _isProcessing = false; StateService.CurrentUserId = auth.User.Index; StateService.FirstRun = true; SettingsHelper.SetValue(Constants.IsAuthorizedKey, true); ShellViewModel.Navigate(NavigationService); IsWorking = false; }), error => BeginOnUIThread(() => { #if LOG_REGISTRATION TLUtils.WriteLog("auth.signIn error " + error); #endif _lastError = error; IsWorking = false; if (error.TypeEquals(ErrorType.PHONE_NUMBER_UNOCCUPIED)) { _callTimer.Stop(); StateService.SentCode = _sentCode; StateService.ClearNavigationStack = true; NavigationService.UriFor <SignUpViewModel>().Navigate(); } else if (error.TypeEquals(ErrorType.PHONE_CODE_INVALID)) { MessageBox.Show(AppResources.PhoneCodeInvalidString, AppResources.Error, MessageBoxButton.OK); } else if (error.TypeEquals(ErrorType.PHONE_CODE_EMPTY)) { MessageBox.Show(AppResources.PhoneCodeEmpty, AppResources.Error, MessageBoxButton.OK); } else if (error.TypeEquals(ErrorType.PHONE_CODE_EXPIRED)) { MessageBox.Show(AppResources.PhoneCodeExpiredString, AppResources.Error, MessageBoxButton.OK); OnBackKeyPress(); NavigationService.GoBack(); } else if (error.TypeEquals(ErrorType.SESSION_PASSWORD_NEEDED)) { IsWorking = true; MTProtoService.GetPasswordAsync( password => BeginOnUIThread(() => { IsWorking = false; _callTimer.Stop(); StateService.Password = password; StateService.RemoveBackEntry = true; NavigationService.UriFor <ConfirmPasswordViewModel>().Navigate(); }), error2 => { IsWorking = false; Telegram.Api.Helpers.Execute.ShowDebugMessage("account.getPassword error " + error); }); } else if (error.CodeEquals(ErrorCode.FLOOD)) { MessageBox.Show(AppResources.FloodWaitString + Environment.NewLine + "(" + error.Message + ")", AppResources.Error, MessageBoxButton.OK); } else { Telegram.Api.Helpers.Execute.ShowDebugMessage("account.signIn error " + error); } })); }