コード例 #1
0
    private void addNewContact()
    {
        ABAddressBook addressBook = ABAddressBook.Create();

        ABRecord person = ABPerson.Create();

        person.SetValue(ABPerson.kABPersonFirstNameProperty, CFType.FromObject("vitapoly"), null);
        person.SetValue(ABPerson.kABPersonBirthdayProperty, CFType.FromObject(new DateTime(2000, 1, 1)), null);

        addressBook.AddRecord(person, null);

        addressBook.Save(null);

        Log("Added vitapoly to address book.");
    }
コード例 #2
0
    public override bool ShouldContinueAfterSelectingPerson(ABPeoplePickerNavigationController peoplePicker, ABRecord person)
    {
        PersonalTest.Log("Selected: " + person.CopyCompositeName());

        // 0 means person, 1 means organization
        CFType kindCFType = person.CopyValue(ABPerson.kABPersonKindProperty);
        PersonalTest.Log("Type: " + kindCFType.ConvertToInt());

        CFType phonesCFType = person.CopyValue(ABPerson.kABPersonPhoneProperty);
        ABMultiValue phones = phonesCFType.Cast<ABMultiValue>();
        for (int i=0; i<phones.GetCount(); i++) {
            string phoneNumStr = phones.CopyValueAtIndex(i).ConvertToString();
            PersonalTest.Log("Phone number: " + phoneNumStr);
        }

        CFType addressesCFType = person.CopyValue(ABPerson.kABPersonAddressProperty);
        ABMultiValue addresses = addressesCFType.Cast<ABMultiValue>();
        for (int i=0; i<addresses.GetCount(); i++) {
            Dictionary<object, object> address = addresses.CopyValueAtIndex(i).ConvertToObject() as Dictionary<object, object>;
            PersonalTest.Log("Address: " + Json.Serialize(address));
        }

        CFType emailsCFType = person.CopyValue(ABPerson.kABPersonEmailProperty);
        ABMultiValue emails = emailsCFType.Cast<ABMultiValue>();
        for (int i=0; i<emails.GetCount(); i++) {
            string emailStr = emails.CopyValueAtIndex(i).ConvertToString();
            PersonalTest.Log("Email: " + emailStr);
        }

        CFType birthdayCFType = person.CopyValue(ABPerson.kABPersonBirthdayProperty);
        if (birthdayCFType != null)
            PersonalTest.Log("Birthday: " + birthdayCFType.ConvertToDateTime());

        CFType creationDateCFType = person.CopyValue(ABPerson.kABPersonCreationDateProperty);
        PersonalTest.Log("Creation date: " + creationDateCFType.ConvertToDateTime());

        UIApplication.deviceRootViewController.DismissViewController(true, null);
        return false;
    }
コード例 #3
0
 public override bool ShouldContinueAfterSelectingPersonWithPropertyAndIdentifier(ABPeoplePickerNavigationController peoplePicker, ABRecord person, int property, int identifier)
 {
     PersonalTest.Log("ShouldContinueAfterSelectingPerson: " + person.CopyCompositeName() + ", " + property + ", " + identifier);
     return false;
 }
コード例 #4
0
 public override bool ShouldContinueAfterSelectingPersonWithPropertyAndIdentifier(ABPeoplePickerNavigationController peoplePicker, ABRecord person, int property, int identifier)
 {
     PersonalTest.Log("ShouldContinueAfterSelectingPerson: " + person.CopyCompositeName() + ", " + property + ", " + identifier);
     return(false);
 }
コード例 #5
0
    public override bool ShouldContinueAfterSelectingPerson(ABPeoplePickerNavigationController peoplePicker, ABRecord person)
    {
        PersonalTest.Log("Selected: " + person.CopyCompositeName());

        // 0 means person, 1 means organization
        CFType kindCFType = person.CopyValue(ABPerson.kABPersonKindProperty);

        PersonalTest.Log("Type: " + kindCFType.ToInt());

        CFType       phonesCFType = person.CopyValue(ABPerson.kABPersonPhoneProperty);
        ABMultiValue phones       = phonesCFType.Cast <ABMultiValue>();

        for (int i = 0; i < phones.GetCount(); i++)
        {
            string phoneNumStr = phones.CopyValueAtIndex(i).ToString();
            PersonalTest.Log("Phone number: " + phoneNumStr);
        }

        CFType       addressesCFType = person.CopyValue(ABPerson.kABPersonAddressProperty);
        ABMultiValue addresses       = addressesCFType.Cast <ABMultiValue>();

        for (int i = 0; i < addresses.GetCount(); i++)
        {
            Dictionary <object, object> address = addresses.CopyValueAtIndex(i).ToDictionary();
            PersonalTest.Log("Address: " + Json.Serialize(address));
        }

        CFType       emailsCFType = person.CopyValue(ABPerson.kABPersonEmailProperty);
        ABMultiValue emails       = emailsCFType.Cast <ABMultiValue>();

        for (int i = 0; i < emails.GetCount(); i++)
        {
            string emailStr = emails.CopyValueAtIndex(i).ToString();
            PersonalTest.Log("Email: " + emailStr);
        }

        CFType birthdayCFType = person.CopyValue(ABPerson.kABPersonBirthdayProperty);

        if (birthdayCFType != null)
        {
            PersonalTest.Log("Birthday: " + birthdayCFType.ToDateTime());
        }

        CFType creationDateCFType = person.CopyValue(ABPerson.kABPersonCreationDateProperty);

        PersonalTest.Log("Creation date: " + creationDateCFType.ToDateTime());

        UIApplication.deviceRootViewController.DismissViewController(true, null);
        return(false);
    }