0
votes

I am developing windows phone app .In this app i need to integrate with foursquare,So I loaded the url of foursqare in web browser.Web browser loaded the four square login page upto this it is working fine when i enter the login details and press enter,Then i will hide web browser and show the data in a list which came from service.After 10-15 seconds app gets crashes.This crash will not seen in emulator it happens only in phone(lumia 520).In lumia 920 it works fine

my xaml code

                  <Grid Grid.ColumnSpan="2" Name="browserGrid" Visibility="Visible">
                    <phone:WebBrowser x:Name="foursquareBrowser" IsScriptEnabled="True" VerticalAlignment="Top" Height="720"   />
            <!--<ProgressBar x:Name="progressBar" IsIndeterminate="True" Visibility="Collapsed"/>-->


                </Grid>

browser.cs

         void foursquareBrowser_Loaded(object sender, RoutedEventArgs e)
    {
        try
        {
            foursquareBrowser.Navigate(new Uri("https://foursquare.com/oauth2/authorize?client_id=EYXOAIOMY3BNFR3DPB4SCK1JGR1J3FKDES4O5RGE3DDDM5WI&response_type=code&redirect_uri=http://www.visitabudhabi.ae"));
           foursquareBrowser.Navigating+=foursquareBrowser_Navigating;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }



  private void foursquareBrowser_Navigating(object sender, NavigatingEventArgs e)
    {
        try
        {
            if (e.Uri.OriginalString.Contains("https://foursquare.com/login"))
            {
           foursquareBrowser.Navigate(new Uri("https://foursquare.com/oauth2/authorize?client_id=EYXOAIOMY3BNFR3DPB4SCK1JGR1J3FKDES4O5RGE3DDDM5WI&response_type=code&redirect_uri=http://www.visitabudhabi.ae"));
            }
            else if (e.Uri.OriginalString.Contains("code="))
            {

                     uri = e.Uri.OriginalString.ToString().Split(new string[] { "code=" }, StringSplitOptions.None).Last();
                    uri = uri.Remove(uri.Length - 4);
                      WebClient wc = new WebClient();
                    string postData = string.Empty;
                    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                    wc.UploadStringAsync(new Uri("https://foursquare.com/oauth2/access_token?client_id=EYXOAIOMY3BNFR3DPB4SCK1JGR1J3FKDES4O5RGE3DDDM5WI&client_secret=1ROOV3FGYQZMVXV0TB1BRMHRIKB3RHI224M2NV0YFC0XXC1U&grant_type=authorization_code&redirect_uri=http://www.visitabudhabi.ae&code=" + uri, UriKind.Absolute), "POST", postData.ToString());
                    wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc1_UploadStringCompleted);
                    foursquareBrowser.Navigating-=foursquareBrowser_Navigating;  

                }

            }



        }
        catch (Exception ex)
        {

            MessageBox.Show(ex.Message);
        }



    }

It is crashing simply without any debugging information.

1
What does the exception says when you debug it on Lumia 520?parveenkhtkr
Did you happen to find any solution for this? I am facing a similar issue on WP8.1Tulika

1 Answers

0
votes

Check Syntax at this line

foursquareBrowser.Navigate(new Uri("https://foursquare.com/oauth2/authorize?  client_id=EYXOAIOMY3BNFR3DPB4SCK1JGR1J3FKDES4O5RGE3DDDM5WI&response_type=code&redirect_uri=http://www.visitabudhabi.ae"));

It seems to be you missed this from above syntax UriKind.RelativeOrAbsolute

 foursquareBrowser.Navigate(new Uri("https://foursquare.com/oauth2/authorize?client_id=EYXOAIOMY3BNFR3DPB4SCK1JGR1J3FKDES4O5RGE3DDDM5WI&response_type=code&redirect_uri=http://www.visitabudhabi.ae",UriKind.RelativeOrAbsolute));