2

I am using the new Twilio Programmable Voice SDK v2.0.0-beta2

All of the tests (incoming and outgoing calls) in the Quickstart worked fine. Now that I'm trying to actually make and connect calls from one phone with the test app to another phone with the test app (ex. client:david to client:alexa), I have hit a wall.

The only modifications I made to the Twilio application server in Python was to add a few lines to the token() function which allow me to get 2 variables passed in from the App (IDENTITY and CALLER_ID). That seems to work just fine, but every time I press the call button on the app, it calls itself. I have tried everything I can think of without success.

Here is the relevant (I think) Swift code:

func fetchAccessToken() -> String? {
        guard let accessTokenURL = URL(string: baseURLString + accessTokenEndpoint + "caller_id=david&identity=alexa") else {
            return nil
        }
        return try? String.init(contentsOf: accessTokenURL, encoding: .utf8)
    }

This is the function to initiate the call:

@IBAction func placeCall(_ sender: UIButton) {
        guard let accessToken = fetchAccessToken() else {
            return
        }
        outgoingCall = VoiceClient.sharedInstance().call(accessToken, params: [:], delegate: self)

        toggleUIState(isEnabled: false)
        startSpin()
    }

Also, when I install on the first phone, I keep the lines: caller_id=david&identity=alexa Then when I install on the second phone, I change that line to: caller_id=alexa&identity=david

David
  • 95
  • 9

1 Answers1

1

Have you tried passing in the to/from parameters into the request like so:

var params:NSDictionary = ["To" : "+15551111", "From" : "myphonenumber",]

Also, are you sure your accessToken isn't nil at the moment you place the call?

Wes Hager
  • 181
  • 1
  • 6