private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if ((args.Uri.AbsolutePath.Contains("/v2/Graph/Welcome")) && (args.Uri.Query.Length > 12)) { webView.Visibility = Visibility.Collapsed; string id = args.Uri.Query.Substring(11); Debug.WriteLine($"Account Id is: {id}"); SecureKeyStorage.SetAccountId(id); Windows.Storage.ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"] = true; #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed PCExtensionHelper.StartPCExtension(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (PCExtensionHelper.IsSupported) { ToastFunctions.SendUniversalClipboardNoticeToast(); } Frame.GoBack(); } else { loadingProgress.IsIndeterminate = false; loadingProgress.Visibility = Visibility.Collapsed; } }
private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if ((args.Uri.AbsolutePath.Contains("/v3/Graph/Welcome"))) { var queryStrings = QueryHelpers.ParseQuery(args.Uri.Query); if (queryStrings.ContainsKey("accountId") && queryStrings.ContainsKey("token")) { webView.Visibility = Visibility.Collapsed; string id = queryStrings["accountId"][0]; string token = queryStrings["token"][0]; Debug.WriteLine($"Account Id is: '{id}', token is: '{token}'"); SecureKeyStorage.SetAccountId(id); SecureKeyStorage.SetToken(token); if (ApplicationData.Current.LocalSettings.Values.ContainsKey("SendCloudClipboard") && ApplicationData.Current.LocalSettings.Values["SendCloudClipboard"].ToString().ToLower() == "true") { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed PCExtensionHelper.StartPCExtension(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (PCExtensionHelper.IsSupported) { ToastFunctions.SendUniversalClipboardNoticeToast(); } } Frame.GoBack(); } else { // Failed to log in var errorCode = queryStrings.ContainsKey("error") ? queryStrings["error"][0] : "null"; var md = new MessageDialog($"Login failed with error '{errorCode}'. Functionality may be limited."); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed md.ShowAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Frame.GoBack(); } } else { loadingProgress.IsIndeterminate = false; loadingProgress.Visibility = Visibility.Collapsed; } }