Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
kliu committed Nov 30, 2017
1 parent 69e98a3 commit fe7fc85
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 86 deletions.
20 changes: 11 additions & 9 deletions .gitignore
@@ -1,14 +1,5 @@
.DS_Store

# Generated libs
libaudiopairing.so
libsqlcipher.so
libc++_shared.so

# intermediate files
*.o
*.d

# Built application files
*.apk
*.ap_
Expand Down Expand Up @@ -49,3 +40,14 @@ captures/

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json
26 changes: 26 additions & 0 deletions LICENSE
@@ -0,0 +1,26 @@
Except the "com.cisco.spark.android:common-lib" and "com.webex:wme4android-release"
licensed under Cisco EULA
(https://www.cisco.com/c/en/us/products/end-user-license-agreement.html),
everything else is licensed under MIT License below.

MIT License

Copyright (c) 2016-2017 Cisco Systems, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
280 changes: 203 additions & 77 deletions README.md
@@ -1,107 +1,233 @@
# spark-android-sdk
# Cisco Spark Android SDK

> Cisco Spark SDK for android.
[![license](https://img.shields.io/github/license/ciscospark/spark-android-sdk.svg)](https://github.com/ciscospark/spark-android-sdk/blob/master/LICENSE)

## Usage
> The Cisco Spark™ Android SDK
### 1. Add the following repository to your Top-level build.gradle file
The Cisco Spark Android SDK makes it easy to integrate secure and convenient Cisco Spark messaging and calling features in your Android apps.

```
allprojects {
repositories {
jcenter()
maven {
url 'http://engci-maven.cisco.com/artifactory/webex-cca-thirdparty'
}
maven {
url 'http://engci-maven.cisco.com/artifactory/webex-cca-release'
}
maven {
url 'http://engci-maven.cisco.com/artifactory/webex-cca-group'
}
maven {
url 'http://engci-maven.cisco.com/artifactory/androidwb-group/'
}
maven {
url 'http://10.140.253.42:10081/nexus/content/repositories/thirdparty/'
This SDK is built with **Android SDK Tools 25** and requires **Android API Level 21** or later.

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)

## Install

Assuming you already have an Android project, e.g. _MySparkApp_, for your Android app, here are the steps to integrate the Cisco Spark Android SDK into your project using [Gradle](https://gradle.org):

1. Add the following repository to your top-level `build.gradle` file:

```groovy
allprojects {
repositories {
jcenter()
maven {
url 'https://devhub.cisco.com/artifactory/sparksdk/'
}
}
}
}
```
```

### 2. Add spark-android-sdk library in your App build.gradle dependency
2. Add the `spark-android-sdk` library as a dependency for your app in the `build.gradle` file:

```
dependencies { compile 'com.ciscospark:android-sdk:0.0.1' }
```
```groovy
dependencies {
compile('com.ciscospark:androidsdk:0.2.0@aar', {
transitive = true
})
}
```

### 3. Enable multiDex in your App
3. Enable [multidex](https://developer.android.com/studio/build/multidex.html) support for your app:

```
android {
defaultConfig {
multiDexEnabled true
```groovy
android {
defaultConfig {
multiDexEnabled true
}
}
}
```

### 4. Make sure your minSdkVersion is up to 21, Android 5.0
```

4. Exclude rxjava.properties in your packagingOptions :

```
android {
defaultConfig {
minSdkVersion 21
```groovy
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
```
```

### 5. User SparkApplication
## Usage

There're two ways of using SparkApplication
To use the SDK, you will need Cisco Spark integration credentials. If you do not already have a Cisco Spark account, visit the [Cisco Spark for Developers portal](https://developer.ciscospark.com/) to create your account and [register an integration](https://developer.ciscospark.com/authentication.html#registering-your-integration). Your app will need to authenticate users via an [OAuth](https://oauth.net/) grant flow for existing Cisco Spark users or a [JSON Web Token](https://jwt.io/) for guest users without a Cisco Spark account.

1. Direct assign in AndroidManifest.xml
See the [Android SDK area](https://developer.ciscospark.com/sdk-for-android.html) of the Cisco Spark for Developers site for more information about this SDK.

```
<application
android:name="com.ciscospark.core.SparkApplication"
android:theme="@style/AppTheme">
<activity android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
### Examples

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
```
Here are some examples of how to use the Android SDK in your app.

2. Inherit SparkApplication
1. Create a new `Spark` instance using Spark ID authentication ([OAuth](https://oauth.net/)-based):

Create a java class extends SparkApplication
```java
String clientId = "YOUR_CLIENT_ID";
String clientSecret = "YOUR_CLIENT_SECRET";
String scope = "spark:all";
String redirectUri = "Sparkdemoapp://response";

```
import com.ciscospark.core.SparkApplication;
OAuthWebViewAuthenticator authenticator = new OAuthWebViewAuthenticator(clientId, clientSecret, scope, redirectUri);
Spark spark = new Spark(activity.getApplication(), authenticator)
if (!authenticator.isAuthorized()) {
authenticator.authorize(webView, new CompletionHandler<Void>() {
@Override
public void onComplete(Result<Void> result) {
if (!result.isSuccessful()) {
System.out.println("User not authorized");
}
}
});
}
```

public class MyApplication extends SparkApplication {
2. Create a new `Spark` instance using Guest ID authentication ([JWT](https://jwt.io/)-based):

@Override
public void onCreate() {
super.onCreate();
// your code here
```java
JWTAuthenticator authenticator = new JWTAuthenticator();
Spark spark = new Spark(activity.getApplication(), authenticator);
if (!authenticator.isAuthorized()) {
authenticator.authorize(myJwt);
}
```

3. Register the device to send and receive calls:

```java
spark.phone().register(new CompletionHandler<Void>() {
@Override
public void onComplete(Result<Void> result) {
if (result.isSuccessful()) {
// Device registered
}
else {
// Device not registered, and calls will not be sent or received
}
}
});
```

4. Create a new Cisco Spark space, add users to the space, and send a message:

```java
// Create a Cisco Spark space:

spark.rooms().create("Hello World", null, new CompletionHandler<Room>() {
@Override
public void onComplete(Result<Room> result) {
if (result.isSuccessful()) {
Room room = result.getData();
}
else {
SparkError error = result.getError();
}
}
});

// Add a user to a space:

spark.memberships().create(roomId, null, "person@example.com", true, new CompletionHandler<Membership>() {
@Override
public void onComplete(Result<Membership> result) {
if (result.isSuccessful()) {
Membership membership = result.getData();
}
else {
SparkError error = result.getError();
}
}
});

// Send a message to a space:

spark.messages().post(roomId, null, null, "Hello there", null, null, new CompletionHandler<Message>() {
@Override
public void onComplete(Result<Message> result) {
if (result.isSuccessful()) {
Message message = result.getData();
}
else {
SparkError error = result.getError();
}
}
});
```

5. Make an outgoing call:

```java
spark.phone().dial("person@example.com", MediaOption.audioVideo(local, remote), new CompletionHandler<Call>() {
@Override
public void onComplete(Result<Call> result) {
Call call = result.getData();
if (call != null) {
call.setObserver(new CallObserver() {
@Override
public void onRinging(Call call) {

}

}
```
@Override
public void onConnected(Call call) {

}

@Override
public void onDisconnected(CallDisconnectedEvent callDisconnectedEvent) {

}

@Override
public void onMediaChanged(MediaChangedEvent mediaChangedEvent) {

}
});
}
else {
SparkError error = result.getError();
}
}
});
```

6. Receive a call:

```java
spark.phone().setIncomingCallListener(new Phone.IncomingCallListener() {
@Override
public void onIncomingCall(Call call) {
call.answer(MediaOption.audioVideo(local, remote), new CompletionHandler<Void>() {
@Override
public void onComplete(Result<Void> result) {
if (result.isSuccessful()) {
// success
}
else {
SparkError error = result.getError();
}
}
});
}
});
```

Assign it in AndroidManifest.xml
## Contribute

```
<application
android:name=".MyApplication"
android:theme="@style/AppTheme">
</application>
```
Pull requests welcome. To suggest changes to the SDK, please fork this repository and submit a pull request with your changes. Your request will be reviewed by one of the project maintainers.

## License

&copy; 2016-2017 Cisco Systems, Inc. and/or its affiliates. All Rights Reserved.

## Build
See [LICENSE](https://github.com/ciscospark/spark-android-sdk/blob/master/LICENSE) for details.

0 comments on commit fe7fc85

Please sign in to comment.