Twilio Voice SDK: Mobile Voice Calls Integration

Twilio Voice SDK: Mobile Voice Calls Integration The user taps the call button — but the call doesn't go through. Or an incoming call arrives with a 10-second delay. Most often the problem lies in incorrect Twilio Voice integration: Access Token expired, PushKit not configured, CallKit invoked in

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Twilio Voice SDK: Mobile Voice Calls Integration
Complex
~3-5 days

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    895
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    782
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1216
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1079
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1002
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    597

Twilio Voice SDK: Mobile Voice Calls Integration

The user taps the call button — but the call doesn't go through. Or an incoming call arrives with a 10-second delay. Most often the problem lies in incorrect Twilio Voice integration: Access Token expired, PushKit not configured, CallKit invoked in the wrong order. Let's break down how to avoid these errors.

Twilio Programmable Voice SDK is an industrial platform that eliminates the hassle of TURN servers and media servers. Twilio handles media transport (Opus/DTLS/SRTP) and global routing through 90+ data centers. The developer is left with: signaling through Twilio, managing the audio session on the mobile platform, and integration with system call interfaces (CallKit on iOS, ConnectionService on Android). We have 5+ successful Twilio Voice projects under our belt, guaranteeing stable operation in production.

Server-Side Setup: Access Token

Twilio Voice SDK authenticates via short-lived Access Tokens generated by your backend using the Twilio Helper Library. The token contains a VoiceGrant — permissions for incoming and outgoing calls. Typical configuration:

from twilio.jwt.access_token import AccessToken from twilio.jwt.access_token.grants import VoiceGrant token = AccessToken( account_sid=ACCOUNT_SID, signing_key_sid=API_KEY_SID, private_key=API_KEY_SECRET, identity=user_id, ttl=3600 ) token.add_grant(VoiceGrant( outgoing_application_sid=TWIML_APP_SID, incoming_allow=True )) return token.to_jwt() 

The mobile client fetches the token on launch and renews it before expiry. The Twilio SDK notifies via the delegate accessTokenInvalidOrExpired — at this point you need to request a new token and call updateAccessToken. We recommend a TTL of 3600 seconds — a balance between security and refresh frequency. Twilio official documentation confirms this approach.

Steps to generate an Access Token on the server:

  1. Create an API Key in Twilio Console.
  2. Configure a TwiML Application with a webhook URL.
  3. Write an endpoint in Node.js/Python that returns a JWT with VoiceGrant.

Why PushKit is Mandatory for Incoming Calls on iOS

PushKit is the only reliable way to deliver an incoming call in any application state. The APNs VoIP channel guarantees priority delivery. Without PushKit, the app won't receive the signal in the background.

func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) { TwilioVoice.register(accessToken: token, deviceToken: credentials.token) { error in } } func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { TwilioVoice.handleNotification(payload.dictionaryPayload, delegate: self, delegateQueue: nil) // MUST call CallKit reportNewIncomingCall before completion } 

Violating the rule of calling CallKit before completion in the PushKit delegate results in forced app termination by iOS. This is not a warning, it's a crash. Integration with CallKit via TVODefaultAudioDevice — Twilio provides a ready-made AVAudioSession manager that correctly interacts with CallKit.

How to Connect ConnectionService on Android

Dependency: com.twilio:voice-android:6.x.x. The SDK works on top of WebRTC but provides a high-level API.

// Initialization Voice.initialize(context, LogLevel.DEBUG) // Outgoing call val connectOptions = ConnectOptions.Builder(accessToken) .params(mapOf("To" to phoneNumber)) .build() val call = Voice.connect(context, connectOptions, object : Call.Listener { override fun onConnected(call: Call) { /* call established */ } override fun onDisconnected(call: Call, error: CallException?) { /* ended */ } override fun onConnectFailure(call: Call, error: CallException) { /* error */ } }) 

Incoming calls come via FCM. The Twilio SDK handles FCM payload through Voice.handleMessage():

override fun onMessageReceived(message: RemoteMessage) { if (Voice.handleMessage(context, message.data, object : MessageListener { override fun onCallInvite(callInvite: CallInvite) { // show incoming call notification showIncomingCallNotification(callInvite) } override fun onCancelledCallInvite(cancelledInvite: CancelledCallInvite, ...) { // call cancelled before answer } })) { /* this is a Twilio push */ } } 

Answering a call: callInvite.accept(context, callListener). To work correctly with ConnectionService, you must specify the correct android:name in the manifest — otherwise the system won't be able to activate the service.

TwiML and Server-Side Routing

Note: when a mobile client calls via Twilio, the request hits your TwiML Application webhook. The backend responds with TwiML — XML instructions for Twilio:

<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial callerId="+1234567890"> <Client>recipient_user_id</Client> </Dial> </Response> 

For calls to regular phone numbers, use <Number> instead of <Client>. Twilio acts as an intermediary, your server controls routing logic.

Call Recording and Analytics

Recording via TwiML <Record> or programmatically via REST API — available without SDK changes. Twilio stores recordings on its servers, providing a download URL. Call analytics (duration, quality, statuses) — via Twilio Console or REST API. We configure automatic notification of recordings to your CRM.

Twilio Voice vs. Custom WebRTC

Criterion Twilio Programmable Voice Custom WebRTC + TURN
Time to production 1–3 weeks 3–6 months
Infrastructure Zero (ready) TURN server, media server, WebSocket
Additional latency < 50 ms (closest PoP) 0 ms (P2P)
Call recording Built-in Requires development
CallKit/ConnectionService support Built-in Requires implementation
Cost per minute from $0.014 $0.001–0.005 (only TURN)

When to Choose Custom WebRTC?

Twilio Voice adds latency through relay — all media streams go through Twilio data centers, not P2P. For most tasks this is negligible (< 50 ms additional latency at the closest PoP), but in regions without a nearby Twilio data center (Central Asia, parts of Africa) latency may be noticeable. Cost: at high volumes (10,000+ minutes/day) custom WebRTC + TURN is cheaper, but more expensive in development and maintenance. If you need P2P communication without intermediaries — contact us, we'll help you choose the architecture.

Integration Process

Step Actions Duration
1. Twilio account setup TwiML App, API Keys, Push Credentials (FCM/APNs) 1 day
2. Backend implementation Access Token generation, TwiML webhook (Node.js, Python, Go) 2–5 days
3. SDK integration Android (Kotlin) + ConnectionService, iOS (Swift) + CallKit 3–7 days
4. Testing Real devices, bug fixing 2–3 days

Full integration timeline — 1–3 weeks. Infrastructure savings — up to $50,000 in the first year.

What's Included

  • Backend development and setup: Access Token generation, TwiML webhook (Node.js or Python).
  • Twilio Voice SDK integration on iOS (Swift, CallKit) and Android (Kotlin, ConnectionService).
  • PushKit (iOS) and FCM (Android) configuration for incoming calls.
  • Testing on real devices, bug fixing.
  • Integration documentation and operations manual.
  • Team training (up to 2 hours online).

Contact us for a consultation on architecture and pricing. Order Twilio Voice integration from us – get stable calls in 2 weeks.