Search code examples
iostwiliovoip

Need help to understand TwilioVoice iOS access token and VoIP push registration


There are two things that are unclear to me about TwilioVoice for iOS, after having followed the quickstart demo.

  • First, I want my app to be only able to receive phone calls, and not to make some. So I want to know, do I really need to call TwilioVoice.register(accessToken)? Or something with CallKit would be enough?
  • My other question is about access tokens. In the quickstart demo, an access token is fetched every time the user enters ViewController, but since I only want to be able to receive phone calls, I was thinking of fetching access token only in the AppDelegate, but I wonder if I would have issues with the token lifetime?

Thank you for your help,


Solution

    1. Yes, you still need register your device. When user A makes a call to user B, Twilio needs user B's device to be registered so they know where to send the VoIP push notification to. CallKit manages the local on-device call state, it doesn't provide the network side of the call. Twilio provides the network side of the call.
    2. You're correct with this. In our application, we register any time application(_:didRegisterForRemoteNotificationsWithDeviceToken) is called since that's the method that provides your application with the device token you need to pass to Twilio.

    I'd caution against taking Twilio's sample project as a good sample project. I had to rework most of what they did in their example when I built our implementation. There's WAY more state management that needs to be done to nicely integrate with CallKit.