Is it possible to add new contact with the Component Xamarin Mobile?

I try to add a new contact to the address book with the Xamarin.Mobile component from the Component Store.
I see it's possible to create a new contact but I can't figure out how to save the new contact to the users address book.

                    var book = new AddressBook ();
                    book.RequestPermission().ContinueWith (t => {
                        if (!t.Result) {
                            Console.WriteLine ("Permission denied by user or manifest");

                        var newContant = new Xamarin.Contacts.Contact();
                        newContant.FirstName = "Jürgen";

                        ??? book.saveNewContact... ???

                    }, TaskScheduler.FromCurrentSynchronizationContext());

Has anybody tried this before?


  • MarkSmith.8123MarkSmith.8123 USXamarin Team, University, XamUProfessors Xamurai

    I don't believe it supports creation or updating contacts; it only allows for reading contacts from the device. The Contact class should have had an internal constructor to avoid the confusion. You will need to interact directly with the underlying API (if the OS has one) to create new contacts.

  • JuergenKollerJuergenKoller DEUniversity ✭✭

    OK thanks Mark - I've done this for iOS already and was hoping for a cross platform solution to avoid doing it again for Android and Windows.

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    @juergenk If you find a solution, maybe you want to contribute it to the repo/component?

  • JuergenKollerJuergenKoller DEUniversity ✭✭

    Hello Rene, I've done it for iOS and I would like to contribute to the repo. But I've never done this before and don't want to smash anything. Is it possible to get an office hour for this? My questions would be:

    • Github check in and out

    • Is my code ok? Memory leaks? Ugly hacks ...

    • Can I build a new nugget package or is this done by Xamarin?

    I think when I get a quick introduction I can do it for Android too at some later time.

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    @juergenk Sure thing. Please send me a PM to [email protected] with two or three possible appointments (later this week or next week please) and we'll schedule something.

  • JuergenKollerJuergenKoller DEUniversity ✭✭

    Thanks to Rene here is my first GitHub fork adding the save contact function for iOS and Android ;-)

Sign In or Register to comment.