To use Linphone with Xamarin, you need the Xamarin SDK which contains the native libraries for Android and iOS (for each architecture) and the C# wrapper that matches those libraries.
You can find a nightly build here: Snapshots and our latest release here: Releases
The Xamarin SDK embed the following:
- The C# wrapper (named LinphoneWrapper.cs) ;
- The Android libraries for armv7, arm64 and x86_64 ;
- The Linphone java classes as an AAR (liblinphone-sdk.aar) which is required for Android (debug and release flavors) ;
- The iOS libraries for armv7, arm64 and x86_64 (as frameworks) ;
To build the sdk, clone the linphone SDK git repository and follow the README instructions.
This guide has been tested with Visual Studio Community 2019 (version 16.11.5) and SDK version 5.0.48 on an Android 8.1 device.
The sample we provide is a solution using four projects: one for Android, one for iOS, one for the native libraries and a shared one.
The shared one contains most of the UI stuff. It has an application and a default view that allow the user to register his SIP account to a proxy and make/receive calls. It also includes the C# wrapper from the SDK.
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).
Finally, the Liblinphone project contains the native libraries built by linphone-sdk.
In the linphone sdk xamarin zip file, copy from linphone-sdk-android directory either the debug or release AAR into
Xamarin\Xamarin\Liblinphone\liblinphone-sdk.aar
Make sure the new name exactly matches the above. That is: If you decide to take the debug lib linphone-sdk-android-debug.aar
you have to rename it to liblinphone-sdk.aar
(Notice the added "lib" prefix).
Also copy the file
linphone-sdk-ios\linphone-sdk\apple-darwin\share\linphonecs\LinphoneWrapper.cs
into
Xamarin\Xamarin\Xamarin\LinphoneWrapper.cs
(the name must remain the same)
That's all! You can open the solution (or close and reopen if you already have it opened), generate the solution, and deploy the sample app on any Android device.
For the C# wrapper to work, it needs to find the Linphone native libraries. On IOS, 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 !