Now slide the mute switch in the app and try speaking into the computer microphone again. Because you’ve created a phone call between the iOS app and your cell phone should be able to talk into your laptop microphone and hear it on your cell phone and vice-versa. If you provided your own cell phone number, go ahead and answer the call coming from Twilio. Twilio should call the number you provided in the verb. Run the app one more time and this time select menu option 4 to talk to another Taylor Swift fan. In the sendDigit action call the sendInput function we created earlier, passing as the input the value of the pressed buttons Tag property. Create Actions for the remaining buttons and associate them with the existing sendDigit action. In our case we will use it to determine which button was pressed and which digit we should pass to the sendInput function:Ĭreate an Action for the first button and name it sendDigit. The Tag property accepts an integer that allows you to identify specific view objects in the application. The way I like to approach this is to use the same code to handle all of the button presses and use the Buttons Tag attribute to hold the value to send for a specific button press.Īssign the value 1, 2, 3 or 4 to each respective buttons Tag property. To let the user tell the application to send a specific digits add four buttons to the storyboard:Īt this point you could create a separate Action for each button, but that’s a lot of repetitive code. This function first checks to see if we have an active connection and then calls the connection’s sendDigits function, passing it the value of the digit we want to send. ![]() I’m using Ruby and Sinatra to respond to Twilio HTTP request and generate the TwiML, but you can use any language and platform that you like. To do that we’ll have to use some code to dynamically generate that TwiML. Once the caller selects a menu option, we need a second TwiML response that tells Twilio what we want to do next, either playing a song or making a call to another Taylor Swift fan. As part of that request it will pass a parameter named Digits which our application can use to process the caller input. Once one or more tones are entered by the caller, Twilio will make a new HTTP request to the URL we’ve specified in the action parameter. If you want to learn more about creating phone menus using TwiML check out the IVR Phone Tree HowTo.Įach of the DTMF tones is a different frequency and represents a different number. Using the verb tells Twilio to start listening for DTMF tones, the beeps and boops that you hear whenever you press the numbers on the dialpad of your phone and lets a developer like yourself create experiences like the menu we just added to our TwiML app. ![]() ![]() In order to demonstrate how we let a user of our iOS application provide this input, we’ll start by modifying our current TwiML app verb. However, many voice applications are more complex and require the user to provide input so that the system can give the user the information or experience that’s best for them. In the last post we left our TwiML app, the thing that provides the experience to a caller connecting through the instance of Twilio Client, pretty simple, translating some text into speech and then playing an audio file. Let’s get building! Press One to Rock Your Socks Off Of course you can always just skip right ahead and grab the completed code for this post from Github as well, but that’s less fun! ![]() When you’re ready to get moving with this post, make sure you have XCode 7 installed to run the app and of course that you have a Twilio account which is free to sign up for, then go grab the starter project from Github. Just joining us on our journey and want to catch up? I’d encourage you to start by reading through the first and second posts to see where we’ve been. I’ll also demonstrate ways that you can control the audio of a phone call by muting the device microphone and swapping the audio output. In this post I’ll show you how you can generate input tones, called DTMF tones, from the app in order to let a user send input back to our TwiML app. In prior posts we’ve had fun using Swift and Twilio Client to build an app that can make and receive phone calls. Welcome back to my series of posts on using Twilio Client for iOS with Apples awesome new language, Swift.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |