TwilioVoice Class Reference
Inherits from | NSObject |
---|---|
Declared in | TwilioVoice.h |
Overview
TwilioVoice
is the entry point to the Twilio Voice SDK. You can register for VoIP push notifications, make outgoing
Calls, receive CallInvites and manage audio using this class.
CallKit Audio Session Handling
Other Methods
logLevel
The current logging level used by the SDK.
@property (nonatomic, assign, class) TVOLogLevel logLevel
Discussion
The default logging level is TVOLogLevelError
. TwilioVoice
and its components use NSLog internally.
See Also
Declared In
TwilioVoice.h
audioEnabled
Enable or disable the audio device.
@property (nonatomic, assign, getter=isAudioEnabled, class) BOOL audioEnabled
Discussion
The default value for the audio device is enabled. Setting audioEnabled to YES
ensures that the audio
device will be used or will activate the audio device if there is an active Call. Setting audioEnabled to NO
ensures that the audio device will not be started when placing a Call or will disable the audio device if it is
already active. The application should use this method to ensure the audio I/O units are activated and deactivated
properly when using CXProviderDelegate.
Declared In
TwilioVoice.h
region
Defines the region (Twilio data center) used for media and signaling traffic.
@property (nonatomic, copy, nonnull, class) NSString *region
Discussion
The default region uses Global Low Latency routing, which establishes a connection with the closest region to the user. Note: Setting the region during a Call will not apply until all ongoing Calls have ended and a subsequent Call is placed.
Declared In
TwilioVoice.h
+ version
Returns the version of the SDK.
+ (nonnull NSString *)version
Return Value
The version of the SDK.
Declared In
TwilioVoice.h
+ setModule:logLevel:
Sets the logging level for an individual module.
+ (void)setModule:(TVOLogModule)module logLevel:(TVOLogLevel)level
Parameters
module |
The |
---|---|
level |
The |
See Also
Declared In
TwilioVoice.h
Managing VoIP Push Notifications
+ registerWithAccessToken:deviceToken:completion:
Registers for Twilio VoIP push notifications.
+ (void)registerWithAccessToken:(nonnull NSString *)accessToken deviceToken:(nonnull NSString *)deviceToken completion:(nullable void ( ^ ) ( NSError *__nullable error ))completion
Parameters
accessToken |
Twilio Access Token. |
---|---|
deviceToken |
The push registry token for Apple VoIP Service. |
completion |
Callback block to receive the result of the registration. |
Discussion
Registering for push notifications is required to receive incoming Calls through Twilio’s infrastructure. Once you’ve successfully registered it’s not necessary to do so again unless your device token changes.
Declared In
TwilioVoice.h
+ unregisterWithAccessToken:deviceToken:completion:
Unregisters from Twilio VoIP push notifications.
+ (void)unregisterWithAccessToken:(nonnull NSString *)accessToken deviceToken:(nonnull NSString *)deviceToken completion:(nullable void ( ^ ) ( NSError *__nullable error ))completion
Parameters
accessToken |
Twilio Access Token. |
---|---|
deviceToken |
The push registry token for Apple VoIP Service. |
completion |
Callback block to receive the result of the unregistration. |
Discussion
Call this method when you no longer want to receive push notifications for incoming Calls. If your device token changes you should call this method to unregister your previous invalid token.
Declared In
TwilioVoice.h
+ handleNotification:delegate:
Processes an incoming VoIP push notification payload.
+ (void)handleNotification:(nonnull NSDictionary *)payload delegate:(nonnull id<TVONotificationDelegate>)delegate
Parameters
payload |
Push notification payload. |
---|---|
delegate |
A |
Discussion
This method will asynchronously process your notification payload and call the provided delegate on the main dispatch queue.
See Also
Declared In
TwilioVoice.h
Making Outgoing Calls
+ call:params:delegate:
Makes an outgoing Call.
+ (nonnull TVOCall *)call:(nonnull NSString *)accessToken params:(nullable NSDictionary<NSString*,NSString*> *)twiMLParams delegate:(nonnull id<TVOCallDelegate>)delegate
Parameters
accessToken |
Twilio Access Token. |
---|---|
twiMLParams |
Additional parameters to be passed to the TwiML application. |
delegate |
A |
Return Value
A TVOCall
object.
Discussion
This method is guaranteed to return a TVOCall
object. It’s possible for the returned Call to either
succeed or fail to connect. Calls created by this method are automatically assigned an NSUUID
to the
TVOCall.uuid
property.
See Also
Declared In
TwilioVoice.h
CallKitIntegration Methods
+ call:params:uuid:delegate:
Makes an outgoing Call.
+ (nonnull TVOCall *)call:(nonnull NSString *)accessToken params:(nullable NSDictionary<NSString*,NSString*> *)twiMLParams uuid:(nonnull NSUUID *)uuid delegate:(nonnull id<TVOCallDelegate>)delegate
Parameters
accessToken |
Twilio Access Token. |
---|---|
twiMLParams |
Additional parameters to be passed to the TwiML application. |
uuid |
An |
delegate |
A |
Return Value
A TVOCall
object.
Discussion
This method is guaranteed to return a TVOCall
object. It’s possible for the returned Call to either
succeed or fail to connect.
See Also
Declared In
TwilioVoice.h
+ configureAudioSession
Configures, but does not activate the AVAudioSession
.
+ (void)configureAudioSession
Discussion
The application needs to use this method to set up the AVAudioSession
with the desired configuration
before letting the CallKit
framework activate the audio session.
This ensures that the SDK does not configure the AVAudioSession
while making or accepting a Call. The settings
applied by configureAudioSession
will remain for the duration of active Calls. Calling configureAudioSession
applies these settings:
NSError *error = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
mode:AVAudioSessionModeVoiceChat
options:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP
error:&error]
If your use case requires different settings, you can apply them immediately after calling configureAudioSession
and the Call will retain these settings. Some settings may not result in high quality audio playback and/or recording.
Declared In
TwilioVoice.h