private bool AddIdentificationPhoneNumbers( CXCallDirectoryExtensionContext context) { var fileIndex = 0; var fileName = GetPhoneFilePath(fileIndex); int entryIndex = 0; // Read all existing files while (File.Exists(fileName)) { //Console.WriteLine($"Extension dictionary {fileIndex}"); // Memory is limited, so flush memory // after each file is read using (new NSAutoreleasePool()) { // The text files have one phone number per line using (StreamReader sr = new StreamReader(fileName)) { while (sr.Peek() >= 0) { var phoneString = (sr.ReadLine()); // Parse string of format // "4722334455;Company name" var delimiterIndex = phoneString.IndexOf(';'); if (delimiterIndex <= -1 || delimiterIndex > phoneString.Length) { continue; } var phoneNumberString = phoneString.Substring(0, delimiterIndex); if (!long.TryParse(phoneNumberString, out long phoneNumber)) { continue; } //Console.WriteLine($"AddIdentificationEntry {entryIndex} {phoneNumber} {phoneString.Substring(delimiterIndex + 1)}"); // Add phone number to the // phone's call directory context.AddIdentificationEntry( phoneNumber, phoneString.Substring(delimiterIndex + 1) ); entryIndex++; } } // Find filename of next file fileName = GetPhoneFilePath(++fileIndex); } } return(true); }
bool AddIdentificationPhoneNumbers(CXCallDirectoryExtensionContext context) { // Retrieve phone numbers to identify and their identification labels from data store. For optimal performance and memory usage when there are many phone numbers, // consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded. // // Numbers must be provided in numerically ascending order. long[] phoneNumbers = { 18775555555, 18885555555 }; string[] labels = { "Telemarketer", "Local business" }; for (var i = 0; i < phoneNumbers.Length; i++) { long phoneNumber = phoneNumbers[i]; string label = labels[i]; context.AddIdentificationEntry(phoneNumber, label); } return(true); }