3

When using iOS CallKit, I can set a custom ringtone when setting up the CXProviderDelegate instance.

CXProviderDelegate instance contains an instance of CXProvider. CXProvider constructor takes an instance of CXPrividerConfiguration as a parameter. Code looks something like:

public class CallController : CXProviderDelegate
{
    CXCallController cxCallController;

    public CallController()
    {
        cxCallController = new CXCallController();

        configuration = new CXProviderConfiguration("App Name Here...")
        {
            RingtoneSound = "ring.wav", // ring.wav file goes in iOS Resources
        };

        Provider = new CXProvider(configuration);
        Provider.SetDelegate(this, null);
    }
}

This is code is called when doing initial startup of the app. My question is, can the RingtoneSound be configured with CallKit on a PER CALL bases?

What I'm looking to do is at the point of knowing that there is an incoming call and WHO is calling, then adjust the ringtone accordingly. It wouldn't be done when setting up instance of CXProviderDelegate. This is for calls made using a SIP library, not actual phone calls. I tried keeping a reference to the configuration class and changing the ringtone per call, but that does not work.

I cannot rely on contacts to specify ringtones. Is there a way to set per call ringtones and if so, how?

Ken K
  • 799
  • 3
  • 9
  • 18
  • I don't think this can be achieve because I think `CXProvider`, `CXProviderConfiguration` should be configured before the call instead of the call is incoming. Also, in the [document](https://developer.apple.com/documentation/callkit/cxprovider?language=objc), it says A VoIP app should create only one instance of CXProvider and store it for use globally. A CXProvider object is initialized with a CXProviderConfiguration object to specify the behavior and capabilities of calls. – nevermore Oct 21 '19 at 06:26
  • I tried using multiple CSProvider instances, each with a different ringtone configured. This didn't work and goes against the CallKit documentation. – Ken K Oct 24 '19 at 17:22
  • Changing the contents of CXProviderConfiguration after it is handed to the CXProvider (i.e. when a call is incoming) also does not work. – Ken K Oct 24 '19 at 17:23
  • 2
    The only way I found to change the ringtone on a per-call basis is to create a new instance of CXProviderConfiguration and assign it to the Configuration of the CXProvider instance. This does work. – Ken K Oct 24 '19 at 17:24

0 Answers0