Data sharing problem between main app and Call Directory Extension

Muharrem 1 Reputation point
2021-06-11T07:11:29.85+00:00

Hello
There is a Contact list in the main IOS project, I converted this list to text type and saved it with NSUserDefault with SetStringForKey method. However, I cannot access this data from CallDirectoryHandler. What am I missing?

This is AppDelegate :

string testText = "18775555555-Morten Nikolajsen,18885555555-Muharrem Cetin";
var defaultsTest = new NSUserDefaults("group.com.MyAppName", NSUserDefaultsType.SuiteName);
defaultsTest.SetString(testText, "CompanyContacts");
defaultsTest.Synchronize();

LoadApplication(new App());

This is CallDirectoryHandler :

var defaults = new NSUserDefaults("group.com.MyAppName", NSUserDefaultsType.SuiteName);
string phonesStr = defaults.StringForKey("CompanyContacts");

        Console.WriteLine("PhoneNumbers = " + phonesStr);

        string[] contactArray = phonesStr.Split(",");
        long[] phoneNumbers = new long[contactArray.Length];
        string[] labels = new string[contactArray.Length];

        for (int i = 0; i < contactArray.Length; i++)
        {
            string numberAndName = contactArray[i];
            long number = long.Parse(numberAndName.Split("-")[0]);
            string name = numberAndName.Split("-")[1];
            phoneNumbers[i] = number;
            labels[i] = name;
        }

        for (var i = 0; i < phoneNumbers.Length; i++)
        {
            long phoneNumber = phoneNumbers[i];
            string label = labels[i];
            context.AddIdentificationEntry(phoneNumber, label);
        }
Azure Data Catalog
Azure Data Catalog
An Azure service that serves as a system of registration and system of discovery for enterprise data assets.
103 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,003 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.