Xamarin: Reload an iOS CallKit call directory extension from the app
I you want to make a call directory extension for iOS, for identifying or blocking certain phone numbers, you need a way to reload the extension every time you want to add or remove from the list of phone numbers you are blocking.
Published:
To reload the extension, you can either get your users to open their phone's settings and disable the extension and re-enable it or you can reload it programmatically from your app.
To reload the extension manually, follow this procedure:
Open the iPhone's settings
Go to "Phone"
Go to "Identify phone numbers"
Switch your extension off, then on again
To reload the extension programmatically from your app, use this code:
var callDirManager =
CXCallDirectoryManager.SharedInstance;
callDirManager.ReloadExtension(
"com.mycompany.myappname.myextension",
error =>
{
if (error == null)
{
// Reloaded extension successfully
} else {
// Extension failed, see error.Code
// and error.Description for more
// information
}
}
);
Here is Apple's documentation for the error codes : https://developer.apple.com/reference/callkit/cxerrorcodecalldirectorymanagererror.code/
The most common one I have come across is 6, Extension Disabled.