Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

HttpClient/API calls really slow.......( Only on iOS ) Andoird and UWP are good

$
0
0

On Android and UWP, everything is good.

However ONLY for iOS the code just runs/executes really slow. Any ideas?

var uri = new Uri(url);

using (var client = new HttpClient())
{
    var request = (HttpWebRequest)WebRequest.Create(uri);
    request.ContentType = "application/json";
    request.Method = "POST";
    request.ServerCertificateValidationCallback += (s, cert, chain, err) => true;
    request.Headers.Add("Authorization", "Bearer " + accessToken);

    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
    {
        streamWriter.Write(json);
        streamWriter.Flush();
        streamWriter.Close();
    }

    // Connect with Server
    var response = (HttpWebResponse)request.GetResponse();

    // Response
    switch (response.StatusCode)
    {
        case HttpStatusCode.Accepted:
        case HttpStatusCode.OK:
            using (var streamReader = new StreamReader(response.GetResponseStream()))
            {
                var read = streamReader.ReadToEnd();
            }
            break;
    }
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>