{"id":13690237,"url":"https://github.com/twilio/voice-quickstart-ios","last_synced_at":"2025-08-07T01:53:35.979Z","repository":{"id":37833901,"uuid":"68399084","full_name":"twilio/voice-quickstart-ios","owner":"twilio","description":"Twilio Voice Quickstart for iOS with Swift","archived":false,"fork":false,"pushed_at":"2025-02-03T14:49:24.000Z","size":9660,"stargazers_count":185,"open_issues_count":15,"forks_count":98,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-02-03T15:45:52.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/twilio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-16T17:09:17.000Z","updated_at":"2025-01-17T02:02:34.000Z","dependencies_parsed_at":"2023-02-18T09:31:18.205Z","dependency_job_id":"73e911c5-d2ac-428e-95ae-f48d3d650812","html_url":"https://github.com/twilio/voice-quickstart-ios","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Fvoice-quickstart-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Fvoice-quickstart-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Fvoice-quickstart-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Fvoice-quickstart-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twilio","download_url":"https://codeload.github.com/twilio/voice-quickstart-ios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251998722,"owners_count":21678007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T16:00:50.068Z","updated_at":"2025-08-07T01:53:35.955Z","avatar_url":"https://github.com/twilio.png","language":"Objective-C","funding_links":[],"categories":["Objective-C","Swift","Telephony"],"sub_categories":[],"readme":"## Twilio Voice Quickstart for iOS\r\n\r\n\u003e Please see our [iOS 13 Migration Guide](https://github.com/twilio/twilio-voice-ios/blob/Releases/iOS-13-Migration-Guide.md) for the latest information on iOS 13.\r\n\r\n## Get started with Voice on iOS\r\n* [Quickstart](#quickstart) - Run the swift quickstart app\r\n* [Examples](#examples) - Sample applications\r\n\r\n## References\r\n* [Access Tokens](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/access-tokens.md) - Using access tokens\r\n* [Managing Audio Interruptions](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/managing-audio-interruptions.md) - Managing audio interruptions\r\n* [Managing Push Credentials](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/managing-push-credentials.md) - Managing push credentials\r\n* [Managing Regional Push Credentials using Notify Credential Resource API](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/push-credentials-via-notify-api.md) - Create or update push credentials for regional usage\r\n* [More Documentation](#more-documentation) - More documentation related to the Voice iOS SDK\r\n* [Issues and Support](#issues-and-support) - Filing issues and general support\r\n\r\n## Voice iOS SDK Versions\r\n* [Migration Guide from 5.x to 6.x](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/migration-guide-5.x-6.x.md) - Migrating from 5.x to 6.x\r\n* [Migration Guide from 4.x to 5.x](https://github.com/twilio/twilio-voice-ios/blob/Releases/iOS-13-Migration-Guide.md) - Migrating from 4.x to 5.x\r\n* [4.0 New Features](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/new-features-4.0.md) - New features in 4.0\r\n* [Migration Guide from 3.x to 4.x](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/migration-guide-3.x-4.x.md) - Migrating from 3.x to 4.x\r\n* [3.0 New Features](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/new-features-3.0.md) - New features in 3.0\r\n* [Migration Guide from 2.x to 3.x](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/migration-guide-2.x-3.x.md) - Migrating from 2.x to 3.x\r\n\r\n## Quickstart\r\nTo get started with the quickstart application follow these steps. Steps 1-5 will enable the application to make a call. The remaining steps 6-9 will enable the application to receive incoming calls in the form of push notifications using Apple’s VoIP Service.\r\n\r\n1. [Install the TwilioVoice framework](#bullet1)\r\n2. [Use Twilio CLI to deploy access token and TwiML application to Twilio Serverless](#bullet2)\r\n3. [Create a TwiML application for the access token](#bullet3)\r\n4. [Generate an access token for the quickstart](#bullet4)\r\n5. [Run the Swift Quickstart app](#bullet5)\r\n6. [Create a Push Credential with your VoIP Service Certificate](#bullet6)\r\n7. [Receive an incoming call](#bullet7)\r\n8. [Make client to client call](#bullet8)\r\n9. [Make client to PSTN call](#bullet9)\r\n\r\n### \u003ca name=\"bullet1\"\u003e\u003c/a\u003e1. Install the TwilioVoice framework\r\n\r\n**Swift Package Manager**\r\n\r\nTwilio Voice is now distributed via Swift Package Manager. To consume Twilio Voice using Swift Package Manager, add the `https://github.com/twilio/twilio-voice-ios` repository as a `Swift Pacakge`.\r\n\r\n### \u003ca name=\"bullet2\"\u003e\u003c/a\u003e2. Use Twilio CLI to deploy access token and TwiML application to Twilio Serverless\r\n\r\nYou must have the following installed:\r\n\r\n* [Node.js v10+](https://nodejs.org/en/download/)\r\n* NPM v6+ (comes installed with newer Node versions)\r\n\r\nRun `npm install` to install all dependencies from NPM.\r\n\r\nInstall [twilio-cli](https://www.twilio.com/docs/twilio-cli/quickstart) with:\r\n\r\n    $ npm install -g twilio-cli\r\n\r\nLogin to the Twilio CLI. You will be prompted for your Account SID and Auth Token, both of which you can find on the dashboard of your [Twilio console](https://twilio.com/console).\r\n\r\n    $ twilio login\r\n\r\nOnce successfully logged in, an API Key, a secret get created and stored in your keychain as the `twilio-cli` password in `SKxxxx|secret` format. Please make a note of these values to use them in the `Server/.env` file.\r\n\r\n\u003ckbd\u003e\u003cimg width=\"300px\" src=\"https://github.com/twilio/voice-quickstart-ios/raw/master/Images/keychain-api-key-secret.png\"/\u003e\u003c/kbd\u003e\r\n\r\nThis app requires the [Serverless plug-in](https://github.com/twilio-labs/plugin-serverless). Install the CLI plugin with:\r\n\r\n    $ twilio plugins:install @twilio-labs/plugin-serverless\r\n\r\nBefore deploying, create a `Server/.env` by copying from `Server/.env.example`\r\n\r\n    $ cp Server/.env.example Server/.env\r\n\r\nUpdate `Server/.env` with your Account SID, auth token, API Key and secret\r\n\r\n    ACCOUNT_SID=ACxxxx\r\n    AUTH_TOKEN=xxxxxx\r\n    API_KEY_SID=SKxxxx\r\n    API_SECRET=xxxxxx\r\n    APP_SID=APxxxx (available in step 3)\r\n    PUSH_CREDENTIAL_SID=CRxxxx (available in step 6)\r\n\r\nThe `Server` folder contains a basic server component which can be used to vend access tokens or generate TwiML response for making call to a number or another client. The app is deployed to Twilio Serverless with the `serverless` plug-in:\r\n\r\n    $ cd Server\r\n    $ twilio serverless:deploy\r\n\r\nThe server component that's baked into this quickstart is in Node.js. If you’d like to roll your own or better understand the Twilio Voice server side implementations, please see the list of starter projects in the following supported languages below:\r\n\r\n* [voice-quickstart-server-java](https://github.com/twilio/voice-quickstart-server-java)\r\n* [voice-quickstart-server-node](https://github.com/twilio/voice-quickstart-server-node)\r\n* [voice-quickstart-server-php](https://github.com/twilio/voice-quickstart-server-php)\r\n* [voice-quickstart-server-python](https://github.com/twilio/voice-quickstart-server-python)\r\n\r\nFollow the instructions in the project's README to get the application server up and running locally and accessible via the public Internet.\r\n\r\n### \u003ca name=\"bullet3\"\u003e\u003c/a\u003e3. Create a TwiML application for the Access Token\r\n\r\nNext, we need to create a TwiML application. A TwiML application identifies a public URL for retrieving [TwiML call control instructions](https://www.twilio.com/docs/voice/twiml). When your iOS app makes a call to the Twilio cloud, Twilio will make a webhook request to this URL, your application server will respond with generated TwiML, and Twilio will execute the instructions you’ve provided.\r\n\r\nUse Twilio CLI to create a TwiML app with the `make-call` endpoint you have just deployed (**Note: replace the value of `--voice-url` parameter with your `make-call` endpoint you just deployed to Twilio Serverless**)\r\n\r\n    $ twilio api:core:applications:create \\\r\n        --friendly-name=my-twiml-app \\\r\n        --voice-method=POST \\\r\n        --voice-url=\"https://my-quickstart-dev.twil.io/make-call\"\r\n\r\nYou should receive an Appliciation SID that looks like this\r\n\r\n    APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\r\n### \u003ca name=\"bullet4\"\u003e\u003c/a\u003e4. Generate an access token for the quickstart\r\n\r\nInstall the `token` plug-in\r\n\r\n    $ twilio plugins:install @twilio-labs/plugin-token\r\n\r\nUse the TwiML App SID you just created to generate an access token\r\n\r\n    $ twilio token:voice --identity=alice --voice-app-sid=APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\r\nCopy the access token string. Your iOS app will use this token to connect to Twilio.\r\n\r\n### \u003ca name=\"bullet5\"\u003e\u003c/a\u003e5. Run the Swift Quickstart app\r\n\r\nNow let’s go back to the `VoiceQuickstart.xcworkspace`. Update the placeholder of `accessToken` with access token string you just copied\r\n\r\n```swift\r\nimport UIKit\r\nimport AVFoundation\r\nimport PushKit\r\nimport CallKit\r\nimport TwilioVoice\r\n\r\nlet accessToken = \"PASTE_YOUR_ACCESS_TOKEN_HERE\"\r\nlet twimlParamTo = \"to\"\r\n\r\nlet kCachedDeviceToken = \"CachedDeviceToken\"\r\n\r\nclass ViewController: UIViewController {\r\n    ...\r\n}\r\n```\r\n\r\nBuild and run the app. Leave the text field empty and press the call button to start a call. You will hear the congratulatory message. Support for dialing another client or number is described in steps 8 and 9. Tap \"Hang Up\" to disconnect.\r\n\r\n\u003ckbd\u003e\u003cimg width=\"300px\" src=\"https://github.com/twilio/voice-quickstart-ios/raw/master/Images/hang-up.png\"/\u003e\u003c/kbd\u003e\r\n\r\n### \u003ca name=\"bullet6\"\u003e\u003c/a\u003e6. Create a Push Credential with your VoIP Service Certificate\r\n\r\nThe Programmable Voice SDK uses Apple’s VoIP Services to let your application know when it is receiving an incoming call. If you want your users to receive incoming calls, you’ll need to enable VoIP Services in your application and generate a VoIP Services Certificate.\r\n\r\nGo to [Apple Developer portal](https://developer.apple.com/) and generate a VoIP Service Certificate.\r\n\r\nOnce you have generated the VoIP Services Certificate, you will need to provide the certificate and key to Twilio so that Twilio can send push notifications to your app on your behalf.\r\n\r\nExport your VoIP Service Certificate as a `.p12` file from *Keychain Access* and extract the certificate and private key from the `.p12` file using the `openssl` command. \r\n\r\n    $ openssl pkcs12 -in PATH_TO_YOUR_P12 -nokeys -out cert.pem -nodes\r\n    $ openssl x509 -in cert.pem -out cert.pem\r\n    $ openssl pkcs12 -in PATH_TO_YOUR_P12 -nocerts -out key.pem -nodes\r\n    $ openssl rsa -in key.pem -out key.pem\r\n\r\n**Note: if you run into the unsupported encryption algorithm (RC2-40-CBC) issue like below, try adding `-legacy` to the `openssl pkcs12` command.**\r\n\r\n```\r\nError outputting keys and certificates\r\nC0EF094DF87F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:355:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()\r\n```\r\n\r\nUse Twilio CLI to create a Push Credential using the cert and key.\r\n\r\n    $ twilio api:chat:v2:credentials:create \\\r\n        --type=apn \\\r\n        --sandbox \\\r\n        --friendly-name=\"voice-push-credential (sandbox)\" \\\r\n        --certificate=\"$(cat PATH_TO_CERT_PEM)\" \\\r\n        --private-key=\"$(cat PATH_TO_KEY_PEM)\"\r\n\r\nThis will return a Push Credential SID that looks like this\r\n\r\n    CRxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n    \r\nThe `--sandbox` option tells Twilio to send the notification requests to the sandbox endpoint of Apple's APNS service. Once the app is ready for distribution or store submission, create a separate Push Credential with a new VoIP Service certificate **without** the `--sandbox` option.\r\n\r\n**Note: we strongly recommend using different Twilio accounts (or subaccounts) to separate VoIP push notification requests for development and production apps.**\r\n\r\nNow let's generate another access token and add the Push Credential to the Voice Grant.\r\n\r\n    $ twilio token:voice \\\r\n        --identity=alice \\\r\n        --voice-app-sid=APxxxx \\\r\n        --push-credential-sid=CRxxxxs\r\n\r\n### \u003ca name=\"bullet7\"\u003e\u003c/a\u003e7. Receive an incoming call\r\n\r\nYou are now ready to receive incoming calls. Update your app with the access token generated from step 6 and rebuild your app. The `TwilioVoiceSDK.register()` method will register your mobile client with the PushKit device token as well as the access token. Once registered, hit your application server's **/place-call** endpoint: `https://my-quickstart-dev.twil.io/place-call?to=alice`. This will trigger a Twilio REST API request that will make an inbound call to the identity registered on your mobile app. Once your app accepts the call, you should hear a congratulatory message.\r\n\r\nRegister your mobile client with the PushKit device token:\r\n\r\n```.swift\r\n    TwilioVoiceSDK.register(accessToken: accessToken, deviceToken: cachedDeviceToken) { error in\r\n        if let error = error {\r\n            NSLog(\"An error occurred while registering: \\(error.localizedDescription)\")\r\n        } else {\r\n            NSLog(\"Successfully registered for VoIP push notifications.\")                \r\n        }\r\n    }\r\n```\r\n\r\nPlease note that your application must have `voip` enabled in the `UIBackgroundModes` of your app's plist in order to be able to receive push notifications.\r\n\r\n\u003ckbd\u003e\u003cimg width=\"300px\" src=\"https://github.com/twilio/voice-quickstart-ios/raw/master/Images/incoming-call.png\"/\u003e\u003c/kbd\u003e\r\n\r\n### \u003ca name=\"bullet8\"\u003e\u003c/a\u003e8. Make client to client call\r\n\r\nTo make client to client calls, you need the application running on two devices. To run the application on an additional device, make sure you use a different identity in your access token when registering the new device. \r\n\r\nUse the text field to specify the identity of the call receiver, then tap the \"Call\" button to make a call. The TwiML parameters used in `TwilioVoice.connect()` method should match the name used in the server.\r\n\r\n\u003ckbd\u003e\u003cimg width=\"300px\" src=\"https://github.com/twilio/voice-quickstart-ios/raw/master/Images/client-to-client.png\"/\u003e\u003c/kbd\u003e\r\n\r\n### \u003ca name=\"bullet9\"\u003e\u003c/a\u003e9. Make client to PSTN call\r\n\r\nTo make client to number calls, first get a verified Twilio number to your account via https://www.twilio.com/console/phone-numbers/verified. Update your server code and replace the `callerNumber` variable with the verified number. Restart the server so it uses the new value.\r\n\r\n\u003ckbd\u003e\u003cimg width=\"300px\" src=\"https://github.com/twilio/voice-quickstart-ios/raw/master/Images/client-to-pstn.png\"/\u003e\u003c/kbd\u003e\r\n\r\n## \u003ca name=\"examples\"\u003e\u003c/a\u003e Examples\r\n\r\nYou will also find additional examples that provide more advanced use cases of the Voice SDK:\r\n\r\n- [AudioDevice](https://github.com/twilio/voice-quickstart-ios/tree/master/AudioDeviceExample) - Provide your own means to playback and record audio using a custom `TVOAudioDevice` and [CoreAudio](https://developer.apple.com/documentation/coreaudio).\r\n- [Making calls from history](https://github.com/twilio/voice-quickstart-ios/blob/master/Docs/call-from-history.md) - Use the `INStartAudioCallIntent` in the user activity delegate method to start a call from the history.\r\n\r\n## More Documentation\r\n\r\nYou can find the API documentation of the Voice SDK:\r\n\r\n* [TwilioVoice SDK API Doc](https://twilio.github.io/twilio-voice-ios/docs/latest/)\r\n\r\n## Twilio Helper Libraries\r\n\r\nTo learn more about how to use TwiML and the Programmable Voice Calls API, check out our TwiML quickstarts:\r\n\r\n* [TwiML Quickstart for Python](https://www.twilio.com/docs/voice/quickstart/python)\r\n* [TwiML Quickstart for Ruby](https://www.twilio.com/docs/voice/quickstart/ruby)\r\n* [TwiML Quickstart for PHP](https://www.twilio.com/docs/voice/quickstart/php)\r\n* [TwiML Quickstart for Java](https://www.twilio.com/docs/voice/quickstart/java)\r\n* [TwiML Quickstart for C#](https://www.twilio.com/docs/voice/quickstart/csharp)\r\n\r\n## Issues and Support\r\n\r\nPlease file any issues you find here on Github: [Voice Swift Quickstart](https://github.com/twilio/voice-quickstart-ios).\r\nPlease ensure that you are not sharing any\r\n[Personally Identifiable Information(PII)](https://www.twilio.com/docs/glossary/what-is-personally-identifiable-information-pii)\r\nor sensitive account information (API keys, credentials, etc.) when reporting an issue.\r\n\r\nFor general inquiries related to the Voice SDK you can [file a support ticket](https://support.twilio.com/hc/en-us/requests/new).\r\n\r\n## License\r\n\r\nMIT\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Fvoice-quickstart-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilio%2Fvoice-quickstart-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Fvoice-quickstart-ios/lists"}