Giter VIP home page Giter VIP logo

ti.vonage's Introduction

Vonage module for Appcelerator Titanium



Buy Me A Coke donate button

Requirements

  • Titanium SDK 9+ (Android), 9.2.0+ (iOS)
  • Vonage (formerly OpenTok) account
  • For Android: Add the following like to your [app]/platform/android/build.gradle
repositories {
  mavenCentral()
}

and <uses-sdk android:minSdkVersion="23"/> in you tiapp.xml.

  • For iOS: Add the following privacy keys to the section of your tiapp.xml:
<key>NSCameraUsageDescription</key>
<string>We need to access your camera (use your own description)</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need to access your microphone (use your own description)</string>

API

Properties

  • apiKey
  • sessionId
  • token
  • audioOnly (creation only)

Methods

  • connect
  • disconnect

Events

  • ready
  • disconnected
  • streamReceived: view, userType, streamId, connectionData, connectionId, connectionCreationTime
  • streamDropped
  • sessionError
  • streamCreated
  • streamDestroyed
  • error

How to use it

Listen to the streamReceived event. It will return a view with the videos. You'll add those views to your normal Ti app. The userType and streamId will help you to e.g. remove them later again if a participant will disconnect.

Example

<modules>
    <module>ti.vonage</module>
</modules>
import TiVonage from 'ti.vonage';

const API_KEY = ''; // Get from https://tokbox.com/developer/
const SESSION_ID = ''; // Get from https://tokbox.com/developer/tools/playground/
const TOKEN = ''; // Get from https://tokbox.com/developer/tools/playground/
const AUDIO_ONLY = false;

function onOpen() {
  // iOS requires some privacy permissions first
  Ti.Media.requestCameraPermissions(event => {
    if (!event.success) {
      alert('No access to camera!');
    }

    Ti.Media.requestAudioRecorderPermissions(event => {
      if (!event.success) {
        alert('No access to microphone!');
      }

      TiVonage.initialize();
    });
  });
}

TiVonage.addEventListener('ready', () => {
  console.log('ready');
});

TiVonage.addEventListener('streamReceived', event => {
  // view with the camera stream:
  const view = Ti.UI.createView({
    height: 190,
    width: 190
  });

  view.add(event.view);
  window.add(view);

  console.log('Type:', event.userType);
  if (event.userType == 'subscriber') {
    console.log('Stream id:', event.streamId);
    console.log('Connection data:', event.connectionData);
    console.log('Connection id:', event.connectionId);
    console.log('Connection time:', event.connectionCreationTime);
  }
});

TiVonage.addEventListener('streamDropped', event => {
  console.log(event.userType, event.streamId);
});

function onClickConnect() {
  TiVonage.apiKey = API_KEY;
  TiVonage.sessionId = SESSION_ID;
  TiVonage.token = TOKEN;
  TiVonage.audioOnly = AUDIO_ONLY;

  TiVonage.connect();
}

function onClickDisconnect() {
  TiVonage.disconnect();
}

const window = Ti.UI.createWindow();
const btn = Ti.UI.createButton({ title: 'Connect' });

window.addEventListener('open', onOpen);
btn.addEventListener('click', onClickConnect);

window.add(btn);
window.open();

License

Apache 2.0

Author

ti.vonage's People

Contributors

hansemannn avatar m1ga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

elusu hansemannn

ti.vonage's Issues

remove permission check

remove easypermissions, add info to readme + example to use the normal ti permisssionrequest

Change in build.gradle repo for new version 2.20.0

Hi,

I have a module for Vonage that we had built for us, it's almost the same as yours. Vonage came out with a new version 2.20.0 SDK for iOS and Android, and there are some changes in how the repos are handled.

From what I can gather, it looks like we need to simply replace

maven { url 'https://tokbox.bintray.com/maven' }

with

mavenCentral()

according to the docs here

https://tokbox.com/developer/sdks/android/#creating

I've done that, but when building my module I'm getting the following error, which looks to me as if the appc cli can't find the sdk in maven.

[INFO] [GRADLE]
[INFO] [GRADLE] > Task :module:preBuild
[INFO] [GRADLE] > Task :module:preReleaseBuild
[INFO] [GRADLE] > Task :module:compileReleaseAidl NO-SOURCE
[INFO] [GRADLE] > Task :module:compileReleaseRenderscript NO-SOURCE
[INFO] [GRADLE] > Task :module:generateReleaseBuildConfig UP-TO-DATE
[INFO] [GRADLE] > Task :module:generateReleaseResValues UP-TO-DATE
[INFO] [GRADLE] > Task :module:generateReleaseResources UP-TO-DATE
[INFO] [GRADLE] > Task :module:packageReleaseResources UP-TO-DATE
[INFO] [GRADLE] > Task :module:parseReleaseLocalResources UP-TO-DATE
[INFO] [GRADLE] > Task :module:processReleaseManifest UP-TO-DATE
[INFO] [GRADLE] > Task :module:generateReleaseRFile FAILED
[ERROR] [GRADLE]
[ERROR] [GRADLE] FAILURE: Build failed with an exception.
[ERROR] [GRADLE]
[ERROR] [GRADLE] * What went wrong:
[ERROR] [GRADLE] Execution failed for task ':module:generateReleaseRFile'.
[ERROR] [GRADLE] > Could not resolve all files for configuration ':module:releaseCompileClasspath'.
[ERROR] [GRADLE] > Could not find :unspecified:.
[ERROR] [GRADLE] Required by:
[ERROR] [GRADLE] project :module > com.opentok.android:opentok-android-sdk:2.20.0
[ERROR] [GRADLE]
[ERROR] [GRADLE] * Try:
[ERROR] [GRADLE] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[ERROR] [GRADLE]
[ERROR] [GRADLE] * Get more help at https://help.gradle.org
[ERROR] [GRADLE]
[ERROR] [GRADLE] BUILD FAILED in 1s
[INFO] [GRADLE] 7 actionable tasks: 2 executed, 5 up-to-date
[ERROR] "gradlew" tool returned exit code: 1
[ERROR] An error occurred during build after 2s 987ms
[ERROR] "gradlew" tool returned exit code: 1

I was hoping that maybe you could build your version targeting the new version, with the changes to the repo and see if you get the same error? I could possibly be missing something as I'm not 100% familiar with how the gradle / maven system works.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.