In the upcoming days/weeks, Xamarin will release a whole set of new versions for its products to develop cross-platform mobile applications.
One of the most important (from my perspective) is Xamarin Studio 6.0 which will include lots of new features. If you want more information about those features, you can find a complete list on this page.
Today, I would like to talk about one of them which allows you to choose which implementation you want to use for network communications for your application iOS.
When you want to write cross-platform mobile applications, you avoid to use platform-specific APIs such as NSURLSession in iOS. Instead, you will prefer to use APIs that are available on all platforms such as the HttpClient class available in the .NET framework.
While this solution has many benefits for reusing your code on all platforms, the performance is worse than using specific API to the platform.
Fortunately, Xamarin Studio 6.0 (available on the Beta channel at this time) will introduce an option to use the underlying native APIs (NSURLSession, CFNetwork…) above HttpClient.
To activate this option, you just have to edit your Xamarin.iOS project settings and to go to the iOS Build section. On the screenshot below, you can see that 2 new options are available :
- HttpClient Implementation
- SSL / TLS Implementation
By default, your project will use the .NET implementation but you can switch to native APIs.
There are many choices available and if you want more details, leave your cursor on the “blue I” on the right side of the selection lists. Below, the details about choices available for the HttpClient implementation.
As mentioned in this tooltip, the usage of native APIs will result of better performance, support for latest standards (e.g. TLS 1.2) and smaller executable size.