Skip to content

Commit

Permalink
Merge pull request #7 from jefflinwood/master
Browse files Browse the repository at this point in the history
Android PhoneGap Plugin for Twilio Client
  • Loading branch information
stevegraham committed Aug 17, 2016
2 parents 562c9bc + 596f846 commit fc9bb0b
Show file tree
Hide file tree
Showing 8 changed files with 1,151 additions and 221 deletions.
83 changes: 74 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,84 @@
# Twilio Client Phonegap plugins
# Twilio Client Phonegap plugins for iOS and Android (version 1.0.7)

This is a Phonegap plugin that exposes the same JS API as Twilio Client for web as much as possible, meaning you should be able to use the same Twilio Client code from your web application inside of your Phonegap application with few if any modifications.
These are Phonegap plugins that expose the same JS API as Twilio Client for web as much as possible, meaning you should be able to use the same Twilio Client code from your web application inside of your Phonegap application with few if any modifications.

# Latest versions tested with this plugin
#### (as of August 16, 2016)
- Cordova 6.3.1
- Cordova Android 5.2.1
- Cordova iOS 4.1.0
- Twilio Client for iOS 1.2.8
- Twilio Client for Android 1.2.17
- XCode 7.3
- Android SDK 23

# Android Gradle Support
- Version 1.0.6 and above now downloads the latest version of the Twilio SDK from jcenter - you will need to use the Cordova Android plugin 5.2.1 for this, as the version of Gradle needed is 2.1.3, and 5.2.1 also includes jcenter as a default repository.

# Android Support Library
- Versions 1.0.4 and earlier of the plugin required you to include the Android support library v4 in the lib. Cordova now has a solution for requiring Android libs through Gradle dependencies. This will save you a step on installation, as well as making this plugin (as of versin 1.0.5) compatible with other plugins such as the PhoneGap Push plugin. One handy tip I found on that plugin is that you may need to update your Android support library using this command line tool, if you get an error saying that the Android Support v4 library can not be found:

`android update sdk --no-ui --filter "extra"`

Please file an issue if you have problems with the Android support library or any compatibility issues with other plugins.

# Example application
https://github.com/jefflinwood/TwilioClientPhoneGapExampleApp

# PhoneGap/Cordova Overview

- Install the most recent version of Cordova (as of this writing, 6.3.1 tools - http://http://cordova.apache.org/
- Install plugman - https://github.com/apache/cordova-plugman

# Both Platforms at once

##Instructions
```
cordova plugin add https://github.com/jefflinwood/twilio_client_phonegap.git
```

# iOS only

##Instructions

```
plugman install --platform ios --project platforms/ios --plugin https://github.com/jefflinwood/twilio_client_phonegap.git
```

- Follow the directions to create a new PhoneGap/Cordova iOS application.

- Follow the instructions in the Twilio iOS client quickstart, e.g. copy headers and static lib into your xcode project, link required frameworks, linker flags, etc.
- After installing the Twilio Client plugin, you will need to download and install the Twilio Client SDK for iOS - follow the directions provided after plugman finishes.

- Copy the Objective-C files into the `plugins` directory of your Phonegap project, and the JavaScript file into the `www` directory.
# Android only

## Instructions

```
plugman install --platform android --project platforms/android --plugin https://github.com/jefflinwood/twilio_client_phonegap.git
```

## Additional Features

In addition to the standard features of the Twilio Client JS Library, you can also use the included showNotification and cancelNotification functions to display a UILocalNotifcation to the user when during an incoming call while the app is running in the background:

```javascript
Twilio.Connection.showNotification("Notification Text", "notification_sound.wav");
```

```javascript
Twilio.Connection.cancelNotification();
```

You can also turn the device's speaker phone on or off during a call using the following method:

```javascript
Twilio.Connection.setSpeaker("on");
```

- Add a new plugin XML item in config.xml:
<feature name="TCPlugin">
<param name="ios-package" value="TCPlugin" />
</feature>
## Changelog
- 1.0.7 - Added Marshmallow/SDK 23 support for runtime permissions
- 1.0.6 - Updated Android platform for plugin to pull in Twilio Android SDK using Gradle

## Limitations

Expand Down
191 changes: 0 additions & 191 deletions iOS/TCPlugin.m

This file was deleted.

78 changes: 78 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugins.twilioclient"
version="1.0.7">

<name>TwilioClient</name>
<description>Use the native Twilio Client for iOS or Android with Cordova/PhoneGap and the Twilio Client JavaScript API</description>
<author>Stevie Graham/Lyle Pratt/Jeff Linwood</author>
<license>Apache</license>

<asset src="www/tcPlugin.js" target="js/tcPlugin.js" />

<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.phonegap.plugins.twilioclient.IncomingConnectionActivity" android:theme="@android:style/Theme.NoDisplay"/>
<service android:name="com.twilio.client.TwilioClientService" android:exported="false" />
</config-file>

<config-file target="res/xml/config.xml" parent="/widget">
<feature name="TCPlugin">
<param name="android-package" value="com.phonegap.plugins.twilioclient.TCPlugin"/>
</feature>
</config-file>

<framework src="com.android.support:support-v4:+" />
<framework src="com.twilio:client-android:1.2.17"/>


<source-file src="src/android/com/phonegap/plugins/twilioclient/IncomingConnectionActivity.java"
target-dir="src/com/phonegap/plugins/twilioclient" />
<source-file src="src/android/com/phonegap/plugins/twilioclient/TCPlugin.java"
target-dir="src/com/phonegap/plugins/twilioclient" />
</platform>

<!-- ios -->
<platform name="ios">
<!-- Add the Twilio Client plugin to the iOS app's config.xml -->
<config-file target="config.xml" parent="widget">
<feature name="TCPlugin">
<param name="ios-package"
value="TCPlugin"/>
</feature>
</config-file>

<!-- Add support for background VOIP and audio to the plist -->
<config-file target="*-Info.plist" parent="UIBackgroundModes">
<array>
<string>voip</string>
<string>audio</string>
</array>
</config-file>


<framework src="AudioToolbox.framework" />
<framework src="AVFoundation.framework" />
<framework src="CFNetwork.framework" />
<framework src="SystemConfiguration.framework" />

<header-file src="src/ios/TCPlugin.h" />
<source-file src="src/ios/TCPlugin.m" />

<info>
You need to download __Twilio Client for iOS__ from https://www.twilio.com/docs/client/ios. Uncompress the download - you will need to follow a few steps that plugman can not do yet:

* Add the Twilio Client static libraries (the .a files in the Libraries folder) to your Xcode project

* Add the Twilio Client headers files (the .h files in the Headers folder) to your Xcode project
</info>
</platform>
</plugin>
Loading

0 comments on commit fc9bb0b

Please sign in to comment.