Forum Cross Platform with Xamarin

Help implementing ModernHttpClient in PCL project

Chris.3704Chris.3704 USUniversity ✭✭


I would like to get some help implementing ModernHttpClient ( in a PCL project in respect to the NativeMessageHandler. I didn't find a good sample on the GitHub page.

Not trying to do anything fancy, just sending a GET request and read response. This would be for Android and iOS platforms.

Any guidance appreciated.



  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    Not really sure what you are asking here. The ModernHttpClient includes all you need to run on iOS and Android. Just install the HTTPClient and ModernHTTPClient NuGet packages, and pass the native message handler when you create your client as normal:

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

    The only gotcha I can think of is there is no dependency in the NuGet packages so you have to remember to install HTTPClient as well - then just read the docs for HTTPClient, the only bit that matters from ModernHttpClient is passing the native message handler when you construct it.

Sign In or Register to comment.