Data sharing problem between main app and Call Directory Extension
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);
}