nexacon_sdk 1.0.0 copy "nexacon_sdk: ^1.0.0" to clipboard
nexacon_sdk: ^1.0.0 copied to clipboard

A comprehensive Flutter SDK for Nexacon API, providing plug-and-play P2P calling with WebRTC and NX signaling.

Nexacon Flutter SDK #

A comprehensive Flutter SDK for Nexacon API, providing plug-and-play P2P calling with WebRTC and NX signaling.

Overview #

Nexacon Flutter SDK enables developers to integrate peer-to-peer audio and video calling into their Flutter applications with minimal setup. The SDK handles all complex signaling, WebRTC peer connections, and ICE negotiation internally.

Installation #

Add the package to your pubspec.yaml:

dependencies:
  nexacon_sdk: ^1.0.0

Install the dependency:

flutter pub get

Getting Started #

1. Initialize the Client #

import 'package:nexacon_sdk/nexacon_sdk.dart';

final client = NexaconClient(
  apiKey: 'your_api_key',
  secretKey: 'your_secret_key',
  baseUrl: 'https://nxservice.quantumvision-tech.com/api/v1.0',
);

2. Generate NX Token #

final nxResponse = await client.auth.generateXMPPToken(
  username: '+255788811191',
);
final nxtoken = nxResponse['token'];
final nxid = nxResponse['jid'];
final wsUrl = nxResponse['nxws'];

3. Create CallManager #

final callManager = await client.createCallManager(
  nxtoken: nxtoken,
  nxid: nxid,
  wsUrl: wsUrl,
  name: 'Your Name',
  onCallStateChanged: (state) {
    // Handle call state changes
  },
  onIncomingCall: (callerName) {
    // Show incoming call UI
  },
  onCallEnded: (reason) {
    // Handle call ended
  },
  onError: (error) {
    // Handle errors
  },
);

4. Make a Call #

// Outgoing call
await callManager.initiateCall(
  to: '+255788811192',
  audio: true,
  video: false,
);

// Accept incoming call
await callManager.acceptCall(
  audio: true,
  video: false,
);

// End call
await callManager.endCall();

5. Call Controls #

// Mute/Unmute
callManager.webrtcService?.toggleAudio(false);

// Speaker toggle
callManager.webrtcService?.toggleSpeaker(true);

// Switch camera
await callManager.webrtcService?.switchCamera();

6. Cleanup #

callManager.dispose();

Platform Configuration #

Android #

Add permissions to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

Set minimum SDK version in android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 21
    }
}

iOS #

Add permissions to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>Camera access is required for video calls</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for audio calls</string>
<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
  <string>voip</string>
</array>

Set minimum iOS version in ios/Podfile:

platform :ios, '12.0'

Features #

  • NX Token Management: Generate and refresh NX tokens for signaling
  • P2P Calling: Full WebRTC peer-to-peer calling with automatic signaling
  • Automatic Reconnection: Built-in WebSocket client with reconnection logic
  • ICE Management: Automatic ICE candidate buffering and exchange
  • Call Controls: Mute, speaker toggle, camera switch
  • Duration Tracking: Built-in call duration timer
  • Cross-platform: Works on iOS, Android, Web, Desktop

Call States #

State Description
idle No active call
calling Outgoing call in progress
incoming Incoming call received
connected Call established
ended Call ended

API Reference #

NexaconClient #

Main client for API interactions.

final client = NexaconClient(
  apiKey: String,
  secretKey: String,
  baseUrl: String,
);

CallManager #

Manages P2P calls with automatic signaling.

final callManager = await client.createCallManager(
  nxtoken: String,
  nxid: String,
  wsUrl: String,
  name: String?,
  onCallStateChanged: Function(CallState)?,
  onIncomingCall: Function(String)?,
  onCallEnded: Function(String)?,
  onError: Function(String)?,
);

Methods

  • initiateCall({required String to, bool audio, bool video}) - Initiate outgoing call
  • acceptCall({bool audio, bool video}) - Accept incoming call
  • rejectCall() - Reject incoming call
  • endCall() - End current call
  • dispose() - Cleanup resources

Auth #

NX token management.

final response = await client.auth.generateXMPPToken(
  username: String,
);

Documentation #

Full documentation available at nexacon-flutter-sdk.readthedocs.io

License #

MIT License - see LICENSE file for details.

1
likes
0
points
379
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter SDK for Nexacon API, providing plug-and-play P2P calling with WebRTC and NX signaling.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_webrtc, http, json_annotation, web_socket_client

More

Packages that depend on nexacon_sdk