I recently got the chance to help out another developer (BetterVoicemail.com) by developing an open source PhoneGap/Cordova plugin for the Twilio Client SDK. If you’re not familiar with Twilio Client, it’s a Voice-over-IP (VoIP) library for web, iOS, and Android that lets you build web pages and mobile apps that can make outgoing phone calls, receive phone calls, chat through the browser, and all kinds of other interesting projects.
The first thing I did was to bring the current iOS code base up to PhoneGap 2.9 compatibility – PhoneGap moves quickly and breaks existing plugins, though they do publish a plugin upgrade guide to follow. After using that as a base, I built a test iOS PhoneGap app that exercised the iOS plugin, because the idea was that the Android plugin would work identically to the iOS plugin.
The Twilio Android Client SDK doesn’t have the same API as the iOS version – in particular, to handle incoming calls, you need to construct a PendingIntent for the Twilio Client SDK to fire off, instead of just registering a delegate with the SDK. So for the Android plugin to work, you need to add an activity to your Android manifest XML file. I used the LocalBroadcastManager to communicate with the plugin, so I could implement a listener that worked exactly like the iOS version. You’ll also need to follow the Twilio Client for Android installation instructions (after using PhoneGap/Cordova to generate your project), which are more complicated than the Twilio Client for iOS installation instructions.
If you want to use the Twilio Client plugin for PhoneGap for Android or iOS, it hasn’t yet been merged back into the original repo yet – so clone it from my GitHub for the time being: (https://github.com/jefflinwood/twilio_client_phonegap)