Access IOS Contacts With Firemonkey in Delphi XE5

IOS Contacts Firemonkey Delphi XE5I had this demo built to allow reading from the IOS contacts using Delphi Firemonkey. It allows you to access the name, phone number, and email addresses on the user’s mobile device in your application using Apple’s native APIs. If you have not already done so you will need to import the AddressBook and AddressBookUI frameworks into Delphi XE5 to be able to compile this demo. Also see the Android Contacts Manager demo for accessing contacts on your Android device.

Update: Keep in mind that your app must first request permission to access the contacts list. I used TDPFAddressBook to do that in my production project and here is the code:

Download the IOS Contacts Demo.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Access IOS Contacts With Firemonkey in Delphi XE5 by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.

16 Responses to Access IOS Contacts With Firemonkey in Delphi XE5

  1. Pingback: Access Android Contacts With Firemonkey in Delphi XE5 | FMX Express

  2. Glenn House says:

    Can you give a more detailed explanation of what you mean by ” import the AddressBook and AddressBookUI frameworks into Delphi XE5″?

    Thanks

    • Admin says:

      Here are the instructions from DPF IOS (http://sourceforge.net/projects/dpfdelphiios/):

      Add this frameworks in the SDK Manager (see Frameworks.png picture after installing)

      /System/Library/Frameworks/AddressBookUI
      /System/Library/Frameworks/AddressBook

      Tools -> Options -> SDK Manager -> Scroll down remote paths listview ->Go Frameworks section -> Select one of framework item (e.g: select /System/Library/Frameworks/UIKit) -> click Add the new path item

      ————————————–
      In XE5 You must be add $(SDKROOT) the beginning of each path on remote machine value
      like this: [ $(SDKROOT)/System/Library/Frameworks ]
      ————————————–

      2-1)
      path on remote machine : /System/Library/Frameworks
      Framework name: AddressBookUI
      include subdirectories: unchecked

      Add again:

      2-2)
      path on remote machine : /System/Library/Frameworks
      Framework name: AddressBook
      include subdirectories: unchecked

      after Ok dialog, click Update local File Cache button.

      • Glenn House says:

        Thanks for the reply – I followed the instructions and the app compiled to my IPhone without error, however, it did not read my contacts into the listbox. The listbox showed “ContactsList(0)” at the top. Is there something else I need to do to for the app to find the contacts on my phone?

        Thanks,

        Glenn

        • Admin says:

          Glenn,

          Yeah I don’t really know. You can debug the source yourself in iOSContactsManager.pas in the procedure TiOSContactsManager.ExtractContacts;. It does some explicit stuff in there like if it doesn’t have an email or phone it may not return anything. Are you on IOS6 or 7? My main test here was with an iPod on IOS6.

          Thanks.

          • Glenn House says:

            IOS6 on an iPhone 5.

            There is one hint/warning during the compile – directory not found for option -‘LC:\Users\kelhedadi.DOCUMALIS\Downloads\DPF.iOS.Native.Components.v7.46’

            Are there some native components I should have installed to make this work?

            Thanks,

            Glenn

          • Admin says:

            I don’t think that error is related as I have a similar error. The demo should be stand alone so you shouldn’t need anything like DFP to make it work. How many contacts are in your device? Do they have phone numbers and/or emails?

          • Glenn House says:

            I have around 150 contacts and they all have either a phone number and/or email address. I loaded the app on my phone with the Delphi debugger and stepped through the FormCreate lines. After fiOSContactManager.ExtractContacts. I checked the value of fiOSContactManager.ContactsCount and it was zero.

            Thanks for your help!

            Glenn

  3. Glenn House says:

    I think it may have something to do with granting access. The Privacy settings should have a request from the app to access the contacts – but I do not see that request being made on my phone. (Settings->Privacy->Contacts)

  4. Pingback: Access Device Contacts With Delphi XE5 Firemonkey On Android And IOS | Delphi XE5 XE6 Firemonkey, Delphi Android, Delphi IOS

  5. Pingback: Accessing contacts from Delphi at iOS and Android | Pavel Jiri Strnad

  6. Fernando says:

    How do I edit a contact?

  7. Pingback: Access Device Contacts With This Free Library In #Delphi XE8 Firemonkey On Android And IOS | Delphi XE5 XE6 XE7 XE8 Firemonkey, Delphi Android, Delphi IOS

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Firemonkey Drawing Demo
Full Featured Delphi XE5 Firemonkey Drawing App Demo On Android And IOS

I had this drawing demo application built for use in another project. I am releasing it here to demonstrate how...

Close