Glance Voice
The Glance Mobile SDK provides an optional in-app calling capability to enable mobile app users to have a voice connection with contact center agents. The Glance Voice feature is available as an addition to the screen-sharing and agent video capabilities, which are core to the Mobile App Sharing SDK. Glance Voice is accessed by the Glance VoIP SDK, which supports both iOS and Android. The VoIP SDK includes optional default user interface elements.
The typical VoIP SDK workflow is as follows:
- A mobile user clicks on help button in mobile app.
- The app initiates a call to a contact center mobile queue via the Glance VoIP SDK.
- The agent picks up the call from queue.
- The mobile user and agent are connected via voice call.
- The agent initiates a mobile app sharing session.
- The mobile user and agent connect via a screen-sharing session.
- Both sessions end when the customer or agent clicks the close button.

Enabling Glance Voice
Before you use Glance Voice, verify that you have added the Glance Mobile SDK for iOS and Android to your application. The Glance Mobile SDK includes Glance Voice functionality. You must also add the Twilio SDK to your project, as detailed below.
Enable Glance Voice for iOS
If you had previously installed the legacy Glance Voip SDK using Cocoapods, remove the dependency on GlanceVoice via Cocoapods, and manually add the Twilio SDK dependency to your iOS project per the documentation below.
To enable Glance Voice for iOS:
- Download the Twilio SDK for iOS version 6.3.0.
- Extract the downloaded file, and find the file named TwilioVoice.framework.
- Copy TwilioVoice.framework into your Xcode iOS project.
- Add TwilioVoice.framework to Embedded Binaries within the Xcode project configuration.
- Verify TwilioVoice.framework is also present within Linked Frameworks and Binaries.
- Add the permission to use the microphone to the iOS application’s Info.plist file:
<key>NSMicrophoneUsageDescription</key>
<string>Glance would like to use your microphone for customer support</string>
Enable Glance Voice for Android
To enable Glance Voice for Android:
- Add the Twilio Programmable Voice SDK (v 5.4.0) to your project gradle file, along with the following network dependencies that are required:
implementation 'com.twilio:voice-android:5.4.0'
implementation 'com.squareup.retrofit2:retrofit:5.4.0'
implementation 'com.squareup.retrofit2:converter-gson:5.4.0'
- Enable microphone permissions in your application. For more information, see Twilio documentation.
- Add this line to your Android Manifest file:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
- Request microphone permissions within your application:
String[] permissions = {Manifest.permission.RECORD_AUDIO};requestPermissions(permissions, 1);
Integration
There are two ways you can integrate Glance Voice into an app: the Default UI or a custom implementation.
-
The Glance Default UI provides a Glance Voice implementation that will work out-of-the-box, in conjunction with Glance Screen Share for iOS and Android.
-
The custom implementation provides the ability to completely control the voice and interface experience.
Default UI with Glance Voice
Configuration
Glance Voice requires a voice group ID
and voiceApiKey
provided by Glance.
To obtain your API key:
- Navigate to https://www.glance.net/Login.asp and log in to your Glance account.
- Go to the Settings tab and scroll to the API Key section at the bottom of the page.
You must call the following to configure the default UI before a session is started with GlanceVisitor.startSession
.
iOS Default Configuration
Objective C:
[GlanceVisitor defaultUI: YES delegate: nil termsUrl:nil
voiceGroupId: 1234 voiceApiKey: @”apiKey” voiceParameters: nil muted: NO];
Swift:
GlanceVisitor.defaultUI(true, delegate: nil, termsUrl: nil,
voiceGroupId: 1234, voiceApiKey: "apiKey", voiceParameters: nil, muted: false)
Android Default Configuration
Java:
Visitor.defaultUI(true, null, "1234", "apiKey", null, false);
Kotlin:
Visitor.defaultUI(true, null, "1234", "apiKey", null, false)
Glance Voice With a Custom Implementation
If you are not going to use the default UI, you must configure your custom implementation to use Glance Voice.
iOS Custom Configuration
Import the Glance Voice header into your implementation:
Objective-C:
#import <Glance_iOS/GlanceVoice.h>
Swift:
Within your Swift implementation import the framework:
import Glance_iOS
Additionally, the following needs to be included in the Objective-C bridging header to access Glance Voice.
#import <Glance_iOS/GlanceVoice.h>
Android Custom Configuration
Include the Glance Voice header file.
Java
import net.glance.glancevoicesdk.GlanceVoice;
Kotlin
import net.glance.glancevoicesdk.GlanceVoice
Availability
Glance Voice requires the Twilio SDK to work. Use the following methods to quickly check if Glance Voice is ready to be used and available.
iOS Availability
Objective-C:
if ([GlanceVoice isAvailable]){
// Twilio SDK present and GlanceVoice is available
}
Swift:
if (GlanceVoice.isAvailable()){
// Twilio SDK present and GlanceVoice is available
}
Android Availability
An instance of the Context object must be passed to the isAvailable function.
Java:
if (GlanceVoice.isAvailable(context)){
// Twilio SDK present and GlanceVoice is available
}
Kotlin:
if (GlanceVoice.isAvailable(context)){
// Twilio SDK present and GlanceVoice is available
}
Events
If you’re doing a custom implementation, you must implement a delegate or listener to react events. Here are the protocols or interfaces for the delegates and listeners and how to set them up on each platform.
iOS Events
The protocol is shared between Objective-C and Swift:
@protocol GlanceVoiceDelegate <NSObject>
@optional
- (void) glanceVoiceAuthenticateDidSucceed:(NSString*)value;
- (void) glanceVoiceAuthenticateDidFail:(NSError*) error;
- (void) glanceVoiceStartDidSucceed;
- (void) glanceVoiceStartDidFail:(NSError*)error;
- (void) glanceVoiceDidDisconnectWithError:(NSError*)error;
- (void) glanceVoiceReconnecting;
- (void) glanceVoiceDidReconnect;
- (void) glanceVoiceReconnectDidTimeout;
@end
Objective-C:
[GlanceVoice setDelegate: this];
Swift:
GlanceVoice.setDelegate(self)
Android Events
public interface GlanceVoice.VoiceListener {
/**
* Called when {@link net.glance.glancevoicesdk.GlanceVoice#authenticate(String, String)} is successful.
*
* @param value The json encoded string with the params needed to make the call.
*/
void authenticationSucceeded(String value);
/**
* Called when {@link net.glance.glancevoicesdk.GlanceVoice#authenticate(String, String)} fails
* @param t A throwable that represents the cause of the failure.
*/
void authenticationFailed(Throwable t);
/**
* Callback for when {@link net.glance.glancevoicesdk.GlanceVoice#startCall(Context, String)} or
{@link net.glance.glancevoicesdk.GlanceVoice#startCall(Context, String, String, String, String)} is successful.
*/
void startSucceeded();
/**
* Called when {@link net.glance.glancevoicesdk.GlanceVoice#startCall(Context, String)} or
{@link net.glance.glancevoicesdk.GlanceVoice#startCall(Context, String, String, String, String)} fails
* @param t A throwable that represents the cause of the failure.
*/
void startFailed(Throwable t);
/**
* Called when the call terminates
*/
void ended(Throwable t);
/**
* Called when a dropped call is attempting to reconnect
*/
void reconnecting();
/**
* Called when a dropped call successfully reconnects
*/
void reconnected();
/**
* Called when a dropped call times out attempting reconnect
*/
void reconnectTimedOut();
}
Android:
GlanceVoice.setListener(listener)
Kotlin:
GlanceVoice.setListener(listener)
Authenticate
To authenticate, the app interacts with the company’s servers (or an AWS Lambda function), which in turn makes a server-side call to the Glance SetupCall API to get the value to pass to StartCall.
Starting a Voice Session
The call to authenticate results in your delegate or listener invoking when the call succeeds or fails. If authentication succeeds, the JSON string passed to the delegate or listener method is required when starting a session. Verify that startCall does in fact succeed or manage its failure with the methods within the delegate or listener.
Start iOS Voice Sessions
Objective-C:
- (void)glanceVoiceAuthenticateDidSucceed:(NSString *)authenticationValue {
[GlanceVoice startCall:authenticationValue];
}
Swift:
func glanceVoiceAuthenticateDidSucceed(_ authenticationValue: String!) {
GlanceVoice.startCall(authenticationValue)
}
Start Android Voice Sessions
Java:
public void authenticationSucceeded(String authenticationValue) {
try {
// mContext is a Context (an Activity or the ApplicationContext)
GlanceVoice.startCall(mContext, authenticationValue);
} catch (SecurityException e) {
// Handle security exception that might occur
}
}
Kotlin:
override fun authenticationSucceeded(authenticationValue : String){
try {
// mContext is a Context (an Activity or the ApplicationContext)
GlanceVoice.startCall(mContext, authenticationValue);
} catch (SecurityException e) {
// Handle security exception that might occur
}
}
Ending a VoiceSession
To end a voice session, invoke endCall.
End an iOS VoiceSession
Objective-C:
[GlanceVoice endCall];
Swift:
GlanceVoice.endCall()
End an Android VoiceSession
Java:
GlanceVoice.endCall();
Kotlin:
GlanceVoice.endCall()
Mute or Unmute a Session
Set the mute state with a boolean yes/no or true/false.
Mute an iOS Session
Objective-C:
[GlanceVoice setMuted: YES];
Swift:
GlanceVoice.setMuted(true)
Mute an Android Session
Java:
GlanceVoice.mute(true);
Kotlin:
GlanceVoice.mute(true)
Enable or Disable Speakerphone
Toggle whether or not the audio of the call is played through the speaker of the phone.
Enable iOS Speakerphone
Objective-C:
[GlanceVoice setSpeakerphoneEnabled:YES];
Swift:
GlanceVoice.setSpeakerphoneEnabled(true)
Enable Android Speakerphone
Java:
GlanceVoice.speakerphone(true);
Kotlin:
GlanceVoice.speakerphone(true)