private async System.Threading.Tasks.Task Authenticate() { while (User == null) { string message = null; try { User = await App.MobileServiceClient .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount); } catch (InvalidOperationException) { message = "You must log in. Login Required"; } if (!string.IsNullOrEmpty(message)) { var dialog = new MessageDialog(message); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } } var user = new User { UserId = User.UserId }; var userTable = App.MobileServiceClient.GetTable<User>(); await userTable.InsertAsync(user); var channelOperation = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); var userDeviceTable = App.MobileServiceClient.GetTable<UserDevice>(); var userDevice = new UserDevice { UserId = user.id, DeviceUri = channelOperation.Uri }; await userDeviceTable.InsertAsync(userDevice); }
private async Task Authenticate() { if (App.MobileServiceClient.LoginInProgress) { return; } while (User == null) { string message = null; try { User = await App.MobileServiceClient .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount); } catch (InvalidOperationException) { message = "You must log in. Login Required"; } if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message); } } var userTable = App.MobileServiceClient.GetTable<User>(); var user = new User { UserId = User.UserId }; await userTable.InsertAsync(user); TheUser = user; }