// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { if (TelegramSession.Instance.AuthorizationExists()) { ContactManager cm = new ContactManager(); Task.Run(() => cm.SyncContacts()); Task.Run(() => new NotificationManager().RegisterPushNotifications()); } }
private async Task Login() { flow.NeedCodeEvent += delegate(Login login) { Deployment.Current.Dispatcher.BeginInvoke( delegate { RestartTimer(); ShowCodeScene(); HeaderBlock.Text = "Your code"; }); }; flow.WrongCodeEvent += delegate(Login login) { Deployment.Current.Dispatcher.BeginInvoke( delegate { ShowCodeScene(); HeaderBlock.Text = "Your code"; codeControl.SetCodeInvalid(); }); }; flow.NeedSignupEvent += delegate(Login login) { Deployment.Current.Dispatcher.BeginInvoke(() => { HeaderBlock.Text = "Your name"; ShowNameScene(); }); }; flow.LoginSuccessEvent += delegate(Login login) { Deployment.Current.Dispatcher.BeginInvoke( delegate { HideProgress(); new NotificationManager().RegisterPushNotifications(); NavigationService.Navigate(new Uri("/UI/Pages/StartPage.xaml", UriKind.Relative)); ContactManager cm = new ContactManager(); Task.Run(() => cm.SyncContacts()); PhotoResult avatarSource = nameControl.GetAvatarSource(); if (avatarSource != null) { Task.Run(async delegate { InputFile file = await TelegramSession.Instance.Files.UploadFile(avatarSource.OriginalFileName, avatarSource.ChosenPhoto, (progress) => { }); photos_Photo photo = await TelegramSession.Instance.Api.photos_uploadProfilePhoto(file, "", TL.inputGeoPointEmpty(), TL.inputPhotoCropAuto()); Photos_photoConstructor photoConstructor = (Photos_photoConstructor)photo; foreach (var user in photoConstructor.users) { TelegramSession.Instance.SaveUser(user); } }); } }); }; Task.Run(() => flow.Start()); // flow.Start(); }