Xamarin.Forms Twilio implementation

This project you can find at: https://github.com/officialdoniald/Xamarin.Forms.Twilio

Twilio created just for Android and iOS libs and not for Xamarin. So we need to create Bindings for Xamarin.Forms and native.

First step: we need to create Android Binding Library(https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.Android.Twilio.Client) and iOS Binding Library(https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.iOS.Twilio.Client) in an Emptys Solution. We have to add the .aar/.jar file(to Jars folder to Android) and .a files (as native reference to iOS) to the Projects. But if you want to just using the completed DLL, just download theese Project from my GitHub, Clean and Rebuild and use the builded DLLs or just added theese Projects to your Application Project as Reference.

After this we need to create a Xamarin.Forms Application(https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC).

We need to add the DLLs or the Projects as Reference to the various Platforms Projects.

Super! We can use the Twilio lib from the Android and iOS Projects. But if we want to use theese from the Forms Application we need to create some Platform Specific implementations and we will call theese throught DependencyService.

Let’s create an Interface in the Forms Application: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC/Implementation/Twilio/ITwilioClient.cs

Now we have to create some events. We will implement the MakeOutBoundCall, Mute and HangOut functions from Twilio. https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC/Helper/GlobalEvents.cs

Great! Now just implement theese in the various Platforms and we will talk about what have to do, when we want to use theese functions without crash.

Android:

Let’s create the interface imaplementation: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.Android/Implementation/Twilio/TwilioClient.cs

Open the MainActivity.cs and create the Twilio object.: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.Android/MainActivity.cs

Very important: we need to change our AndroidManifest.xml file: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.Android/Properties/AndroidManifest.xml. We need to add some uses and service.

Done!

iOS:

https://github.com/officialdoniald/Xamarin.Forms.Twilio/tree/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.iOS

Don’t worry, if there will be some errors, that’s a Visual Studio bug. The project will be built.

Let’s create the interface imaplementation: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.iOS/Implementation/Twilio/TwilioClient.cs

Open the AppDelegate.cs file: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.iOS/AppDelegate.cs

And here we will use the microphone we have to change the Info.plist file: https://github.com/officialdoniald/Xamarin.Forms.Twilio/blob/master/Xamarin.Forms.Twilio.PoC/Xamarin.Forms.Twilio.PoC.iOS/Info.plist

    <key>NSMicrophoneUsageDescription</key>
    <string>YOUR_APP_NAME will use your microphone, when you call someone.</string>

When you make an OutBoundCall you can use a lots of combination of the parameters. See some of theese at: https://www.twilio.com/docs/voice/client/tutorials/outgoing-calls.

10 thoughts on “Xamarin.Forms Twilio implementation”

  1. It’s amazing to pay a quick visit this web page and reading the views of all mates on the topic of this piece of writing, while I am also eager of getting knowledge.|

  2. The the very next time I just read a weblog, Lets hope it doesnt disappoint me about this. Get real, Yes, it was my choice to read, but I really thought youd have some thing interesting to say. All I hear is a few whining about something you could fix if you ever werent too busy in search of attention.

Leave a Reply

Your email address will not be published. Required fields are marked *