public override async void OnPageFinished(WebView view, string url) { base.OnPageFinished(view, url); if (url.Contains("https://contosocabs.azurewebsites.net/oauth/uber?code=")) { int index = url.IndexOf("="); code = url.Substring(index + 1); code = code.Trim(); System.Diagnostics.Debug.WriteLine("ac code :" + code); SendTokenResponse mResp = await mCabsApi.SendToken(token, code); System.Diagnostics.Debug.WriteLine("In webviewclient resp code " + mResp.Code); if (mResp.Code == ResponseCode.SUCCESS) { mEditor.PutBoolean("hasAccounts", true).Apply(); isDone = true; webViewAccountsActivity.StartActivity(new Intent(webViewAccountsActivity, typeof(GettingStartedActivity))); webViewAccountsActivity.Finish(); } else { //webViewAccountsActivity.StartActivity(new Intent(webViewAccountsActivity, typeof(NavigationActivity))); //webViewAccountsActivity.Finish(); } } else { } }
async void WebViewControl_ScriptNotify(object sender, NotifyEventArgs e) { // Be sure to verify the source of the message when performing actions with the data. // As webview can be navigated, you need to check that the message is coming from a page/code // that you trust. string code = e.Value; string token = Windows.Storage.ApplicationData.Current.LocalSettings.Values["Token"].ToString(); CabsAPI api = new CabsAPI(); SendTokenResponse response = await api.SendToken(token, code); if (response.Code == ResponseCode.SUCCESS) { Frame.BackStack.Clear(); Frame.Navigate(typeof(Navigation.NavigationPage), "OPEN_PROFILE"); } else { await new MessageDialog("Cannot Authenticate your account now. Try again later").ShowAsync(); Frame.BackStack.Clear(); Frame.Navigate(typeof(Navigation.NavigationPage), "OPEN_PROFILE"); } }