How to create an iOS call directory extension in Xamarin for blocking thousands of phone numbers

A call directory extension is used to block or identify phone numbers on an iPhone, phone numbers the user don’t have in their contact list.

TL;DR: Because iOS app extensions have very limited resources, it is difficult to load many thousand phone numbers into the call directory without the extension crashing. This is my attempt to get around this issue.

This post expands on Xamarin’s tutorial for how to create a call directory extension, which you probably should read first, here:
Xamarin: Implementing a Call Directory Extension

The end result of that tutorial is a call directory extension that can block or identify two hard coded phone numbers.

Based on Xamarin’s sample code, I have further made an accompanying app that saves some thousand phone numbers in text files. The app saves the phone numbers in files called phonenumbers.0.txt, phonenumbers.1.txt, etc., with a few hundred phone numbers in each file.

It is really important that the phone numbers are in numerical order, smallest number first. You don’t want to do any sorting or filtering in the extension, do all that kind of memory intensive tasks in the app when you create the text files.

Another important nugget of information, is that a phone number has to be saved including the country code. So American phone numbers always start with 1, and Norwegian phone numbers always start with 47.

This is my modified method to add phone numbers from the text files to the phone’s identification directory:

Leave a Reply

Your email address will not be published. Required fields are marked *