Xamarin SDK

To use Linphone with Xamarin, you need the Xamarin SDK which contains the native libraries for Android, iOS  (for each architecture) and the C# wrapper that matches those libraries.

You can build your own SDK (see Linphone SDK README file) or you can download a pre-built ZIP archive with the native libraries for both Android & iOS plus the C# wrapper.

Pre-built SDK are available at in two flavors: releases or nightly builds. Nightly builds are built every night from the master branch of linphone-sdk instead of release branch.

What's in the box

The Xamarin SDK embed the following:

  • The C# wrapper (named LinphoneWrapper.cs) ;
  • The Android libraries for armv7, arm64 (as AAR) ;
  • The iOS libraries for armv7, arm64 and x86_64 (as frameworks) ;
  • A sample solution based on Xamarin Forms for both Android and iOS platforms.

If you want to support an architecture that is not included in our SDK (for example x86), you can compile the libraries by yourself (see above).

Architecture

Once you have our SDK (either built by yourself or a pre-built archive you downloaded), you can open the Xamarin.sln solution inside the Xamarin folder of our sample app.

The sample we provide is a solution using four projects: one for Android, one for iOS, and two shared: one for the native libraries (our SDK), one for the app itself (the shared part).

The Android project contains the Android Manifest for the generated APK and an Activity that will load and display the application from the shared project.

The iOS project does the same thing that the Android one, but for iOS (obviously).

Set-up the SDK

Android

If you haven't done it already, also copy the C# wrapper in linphone-sdk-ios\linphone-sdk\apple-darwin\share\linphonecs\LinphoneWrapper.cs into Xamarin\Xamarin\Xamarin\LinphoneWrapper.cs (the name must remain the same).

For the C# wrapper to work, it needs to find the Linphone native libraries. Here's the procedure to add them to the project:

Copy the AAR with the native libraries (either the debug or the release one) into Xamarin\Xamarin\Liblinphone\liblinphone-sdk.aar (the name must remain the same).

iOS

If you haven't done it already, also copy the C# wrapper in linphone-sdk-ios\linphone-sdk\apple-darwin\share\linphonecs\LinphoneWrapper.cs into Xamarin\Xamarin\Xamarin\LinphoneWrapper.cs (the name must remain the same).

For the C# wrapper to work, it needs to find the Linphone native libraries. Here's the procedure to add them to the project:

  • Import the Frameworks folder with all the frameworks within your Xamarin.iOS project ;
  • Right click on your Xamarin.iOS project then select add -> add native references and select all the frameworks you imported in the project.

Do not forget to add your required permissions in your project Info.plist (i.e: use of microphone etc...) or your app will crash !

Platform specifics

Android

Don't forget to add the required permissions to the AndroidManifest.xml file. Here's the list of all permissions our SDK might need:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Needed to be able to use WifiManager.MulticastLock -->
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- Needed to allow Linphone to install on tablets, since android.permission.CAMERA implies android.hardware.camera and android.hardware.camera.autofocus are required -->
<uses-feature android:name="android.hardware.camera" android:required="false" />

Finally if you are deploying on Android >= 23 ask at runtime the permissions like you would do on a native Android application.

iOS

Created by Sylvain Berfini on 2017/05/10 10:45