Π·Π΅Ρ€ΠΊΠ°Π»ΠΎ ΠΈΠ·
1
0
Π€ΠΎΡ€ΠΊΠ½ΡƒΡ‚ΡŒ 0
HttpClient implementations that use platform-native HTTP clients for πŸš€
ΠŸΠ΅Ρ€Π΅ΠΉΡ‚ΠΈ ΠΊ Ρ„Π°ΠΉΠ»Ρƒ
Paul Betts ff20429874 Fix up license URL 2013-12-19 12:17:51 -08:00
component Version Bump to 1.0.1 2013-11-04 09:30:08 -08:00
samples Removed branding from default images. 2013-11-10 16:59:28 -06:00
src WHY IS THIS NOT THE DEFAULT OMFG 2013-12-19 11:31:24 -08:00
vendor Add NuGet EXEs 2013-12-19 11:41:32 -08:00
.gitignore Merge remote-tracking branch 'origin/pr/12' 2013-10-30 23:17:41 -07:00
.gitmodules added make files support 2013-10-08 13:59:27 -04:00
COPYING Add license 2013-10-24 10:04:42 -07:00
Makefile Add a NuSpec file and a make command to create a NuGet package 2013-12-19 11:54:56 -08:00
ModernHttpClient.nuspec Fix up license URL 2013-12-19 12:17:51 -08:00
ModernHttpClient.sln We need the INTERNET permission 2013-11-01 16:49:32 -07:00
README.md Update README.md 2013-11-07 20:27:17 -08:00

README.md

ModernHttpClient

This library brings the latest platform-specific networking libraries to Xamarin applications via a custom HttpClient handler. Write your app using System.Net.Http, but drop this library in and it will go drastically faster. This is made possible by two native libraries:

Usage

The good news is, you don't have to know either of these two libraries above, using ModernHttpClient is the most boring thing in the world. Here's how it works:

On iOS:

var httpClient = new HttpClient(new AFNetworkHandler());

On Android:

var httpClient = new HttpClient(new OkHttpNetworkHandler());

How can I use this in a PCL?

Using ModernHttpClient from a PCL is fairly easy with some rigging, especially if you've got some sort of IoC/DI setup - request an HttpClient in your PCL, and register it in your app. However, here's what you can do without any external dependencies:

// In your PCL
public static class HttpClientFactory 
{
    public static Func<HttpClient> Get { get; set; }
    
    static HttpClientFactory()
    {
        Get = (() => new HttpClient());
    }
}

// Somewhere else in your PCL
var client = HttpClientFactory.Get();

// In your iOS app (i.e. the startup of your app)
public static class AppDelegate
{
    public void FinishedLaunching(UIApplication app, NSDictionary options)
    {
        HttpClientFactory.Get = (() => new HttpClient(new AFNetworkHandler()));
    }
}

How can I use this in MvvmCross?

Check out Michael Ridland's blog post, Implementing ModernHttpClient in MvvmCross, for more information.

Building

make