简体   繁体   中英

How to programmatically add a new contact to the iOS device from a PC/Mac

I need a way to programmatically add a new contact to iPhone from a computer. Preferably using Python.

Long story short, I have contacts extracted from my old phone, and I want to transfer them to my new iPhone.

A solution that comes to my mind is to fill an addressbook supported by iTunes and then synchronize it with iOS.

But I would like a clean, easy, direct approach over intermixing this and that to find out that it wouldn't work because of something idiotic popped up.

Is there any protocol specification for doing that, or a way to link to iTunes DLLs or dynlibs?

Or perhaps a tweak using Apple Script on Mac.

I solved my personal problem by constructing vCard file containing all contacts from my old phone, then transfering that file to my iPhone manually who happily offered to import all contacts from it into its contacts App.

VCard specification can be found on Wikipedia. It is one nice file format. I used version 2.1 and it worked.

I was afraid that iPhone would accept only XML vCard version, but it worked with 2.1. That's what I really meant in my comment. I wasn't sure which vCard version iOS uses.

It was extremely easy as my old phone gave me all contacts as a bunch of individual vCard files. So I only needed a simple little program to combine them into one file.

Thanks to apraetor for a comment that gave me that idea.

But the way I wanted it done (as I explained in the question) is possible by using LibIMobileDevice library available at:

http://www.libimobiledevice.org/

I didn't have time to experiment but it should work. And anyone searching for a way to do what I wanted should know about this excellent library.

I'd like someone's answer with details on how it is done and the code (for other's benefit), as I wouldn't play with this for some time. I am currently very busy.

I suspect it is something like:

  1. Get all contacts from iPhone

  2. Add new ones or delete old ones

  3. Synchronize back

as I didn't see anything there hinting at direct contact manipulation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM