Skip to content

Bandwidth-Samples/swift-webrtc-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

BandwidthSession & BandwidthUA Integration Guide

Welcome to the BandwidthSession and BandwidthUA integration guide. This comprehensive guide will assist developers in seamlessly integrating the powerful BandwidthSession and BandwidthUA services provided by BandwidthSDK into their Swift applications.

Bandwidth Logo

Table of Contents`

  1. Introduction
  2. Configuration
  3. Event Handling
  4. Usage
  5. Error Handling

Introduction

Integrating Bandwidth's communication services into your Swift applications has never been easier. With this guide, you'll learn how to harness the full potential of BandwidthSession and BandwidthUA to enable voice communication capabilities within your application.

Configuration

Setting Variables

Before configuring the SDK, let's understand the essential variables:

  • BandwidthSession: This variable may initially be null as it will store the result later.
  • BandwidthUA: This represents the main instance of the Bandwidth SDK.

Configuration Steps

To use the BandwidthSDK effectively, you must initialize the connection by following these simple steps:

  1. Configure BandwidthUA: Provide the connection data to establish the communication link.
  2. Configure Account: Set up the necessary account details.

Event Handling

Listening to Call Events

To monitor the status of an ongoing call and react accordingly, you need to implement the BandwidthSessionEventListener in your main application class. Here, you can listen to critical call events, such as:

  • callTerminated: Detect when a call has ended.
  • callProgress: Monitor the progress of an ongoing call.
  • incomingNotify: Receive notifications about incoming calls.

Usage

Making a Call

Now that your SDK is configured, you can initiate calls seamlessly. To make a call, use the makeCall function provided by BandwidthUA. This function takes the phone number and domain as parameters and returns a BandwidthSession instance. Don't forget to set up the listeners to handle call events effectively.

func makeCall() {
    session = bandwidthUA.makeCall(phoneNumber, domain: domain,authToken: oAuthToken)
    if let session = session {
        session.addSessionEventListener(listener: self)
    }
}

Ending a Call

To gracefully terminate an active call, use the terminate method of the BandwidthSession variable stored when making the call. This action will also trigger the callTerminated listener.

/// Terminate the active call.
func terminateCall() {
    if let session = session {
        session.terminate()
    }
}

Additional Functions

BandwidthSession exposes additional functions such as muteAudio(mute: Bool), hold(hold: Bool), and sendDTMF(dtmf: dtmf) that empower you to customize and enhance your voice communication session.

Error Handling

In any application, errors are inevitable, especially in networked operations. Make sure to implement robust error handling mechanisms to catch, manage, and inform users about any errors that may occur. This will ensure a seamless user experience.

About

Swift SDK for Bandwidth In-App Calling

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages