libimobiledevice-win32 icon indicating copy to clipboard operation
libimobiledevice-win32 copied to clipboard

Enanle to use Mobilesync

Open vipinbeni opened this issue 10 years ago • 190 comments

Hi Sir,

I am using this library in my vc++ application for synchronization of contact and i want to list all contact from devices to my application on windows systems . i am using following code

int main(void) { int count, i, err; lockdownd_service_descriptor_t port = NULL; usbmuxd_device_info_t devices; idevice_t idevice; idevice_connection_t connection; lockdownd_client_t ldclient; mobilesync_client_t sync_client = NULL; char *host_id; err = usbmuxd_get_device_list(&devices); if(err != 1) { printf("usbmuxd_get_device_list error %d, exiting.\n", err); close_all(NULL, NULL, NULL, &devices); return 0; } for(count = 0; devices[count].handle > 0; count++); / First device only / err = idevice_new(&idevice, devices[0].udid); if(err != 0) { printf("idevice_new error %d, exiting.\n", err); close_all(NULL, NULL, idevice, &devices); return 0; } err = lockdownd_client_new_with_handshake(idevice, &ldclient, "mobilesync"); if(err != 0) { printf("lockdownd_client_new_with_handshake %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } userpref_get_host_id(&host_id); err = lockdownd_start_service(ldclient, "com.apple.mobilesync", &port); if(err != 0) { printf("lockdownd_start_service %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } err = mobilesync_client_new(idevice, port, &sync_client); if(err != 0) { printf("mobilesync_client_new %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_t data = NULL; plist_t msg = NULL; plist_t response_t = NULL; char * response; / Initial handshake / msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_new_string("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_new_string("SDSyncTypeSlow")); / plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("_EmptyParameterString")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_free(msg); msg = NULL; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } response_t = plist_array_get_item(msg, 0); plist_get_string_val(response_t, &response); if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0) { close_all(sync_client, ldclient, idevice, &devices); return 0; } msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0;; } char * xml = NULL; unsigned int xml_size; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } /_ both checks are voluntary / if(plist_get_parent(msg) == NULL) / check whether it's a root node / if(plist_get_node_type(msg) == PLIST_ARRAY) / check whether root node is an array */ plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml); close_all(sync_client, ldclient, idevice, &devices); return 0; }

But am not getting my contact in xml file .

instead when i am using com.apple.Bookmarks its work fine.

please correct me where i am going wrong please help as i am working on it from many days help me out pls.

Thanks

vipinbeni avatar Sep 11 '14 04:09 vipinbeni

try close idevice icloud sync contact first.

airwolf2026 avatar Sep 11 '14 06:09 airwolf2026

Thanks airwolf2026 for your Quick reply its work now , thanks a lot

but i have a problem now got information like first name, last name ,company name etc correct but not information like Phone number, email ,Street Address,URL ,Date etc not coming in this xml dict.

i got this format out put

< ?xml version="1.0" encoding="UTF-8"? > < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd" > < plist version="1.0" > < dict > < key >last name< /key > < string >Ll222< /string > < key >company name< /key > < string>Ccc222< /string > < key >com.apple.syncservices.RecordEntityName< /key > < string >com.apple.contacts.Contact< /string > < key >first name< /key > < string >BbB222< /string > < key >display as company< /key > < string >person</ string > < /dict > < /plist >

< ?xml version="1.0" encoding="UTF-8"? > < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd" > < plist version="1.0" > < dict > < key >display as company< /key > < string>person< /string > < key >company name< /key > < string>Information Limited < key >notes< /key > < string >


Details Updated 4/10/2012:

Business Address City: new delhi

Business Address State: delhi

Business Address Country/Region: India< /string >
< key >com.apple.syncservices.RecordEntityName< /key >
< string >com.apple.contacts.Contact< /string>
< key >last name< /key >
< string >Talwar< /string >
< key >first name< /key >
< string >Ankur< /string >
< key >department< /key >
< string >Technical Support< /string >

</ dict > </ plist>

please help me how i got all information where to change made in my code please help me

Thanks

vipinbeni avatar Sep 12 '14 03:09 vipinbeni

you should read message until null.like: while(msg!=null) { mobilesync_receive(sync_client, &msg); } idevice send contact infos in diffrent plist.

airwolf2026 avatar Sep 12 '14 07:09 airwolf2026

int main(void) { int count, i, err; lockdownd_service_descriptor_t port = NULL; usbmuxd_device_info_t devices; idevice_t idevice; idevice_connection_t connection; lockdownd_client_t ldclient; mobilesync_client_t sync_client = NULL; char host_id; err = usbmuxd_get_device_list(&devices); if(err != 1) { printf("usbmuxd_get_device_list error %d, exiting.\n", err); close_all(NULL, NULL, NULL, &devices); return 0; } for(count = 0; devices[count].handle > 0; count++); / First device only / err = idevice_new(&idevice, devices[0].udid); if(err != 0) { printf("idevice_new error %d, exiting.\n", err); close_all(NULL, NULL, idevice, &devices); return 0; } err = lockdownd_client_new_with_handshake(idevice, &ldclient, "mobilesync"); if(err != 0) { printf("lockdownd_client_new_with_handshake %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } userpref_get_host_id(&host_id); err = lockdownd_start_service(ldclient, "com.apple.mobilesync", &port); if(err != 0) { printf("lockdownd_start_service %d, exiting.\n", err); close_all(NULL, ldclient, idevice, &devices); return 0; } err = mobilesync_client_new(idevice, port, &sync_client); if(err != 0) { printf("mobilesync_client_new %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_t data = NULL; plist_t msg = NULL; plist_t response_t = NULL; char * response; / Initial handshake / msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_new_string("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_new_string("SDSyncTypeSlow")); / plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("EmptyParameterString")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } plist_free(msg); msg = NULL; err = mobilesync_receive(sync_client, &msg); if(err != 0) { printf("mobilesync_receive %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0; } response_t = plist_array_get_item(msg, 0); plist_get_string_val(response_t, &response); if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0) { close_all(sync_client, ldclient, idevice, &devices); return 0; } msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err); close_all(sync_client, ldclient, idevice, &devices); return 0;; } char * xml = NULL; unsigned int xml_size; err = mobilesync_receive(client, &msg); if(plist_get_parent(msg) == NULL) / check whether it's a root node / if(plist_get_node_type(msg) == PLIST_ARRAY) / check whether root node is an array */ plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml);

while(msg!=NULL)
{
    err = mobilesync_receive(client, &msg);
    if(plist_get_parent(msg) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(msg) == PLIST_ARRAY)     /* check whether root node is an array  */
            plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
}

close_all(sync_client, ldclient, idevice, &devices); return 0; }

i use this but still no phone no come in plist dist while in iphone all have no and email and url etc

while(msg!=NULL) { err = mobilesync_receive(client, &msg);

}

value return -1 ; second time execution

pls help it only show com.apple.contacts.Contacs not com.apple.contacs.Phone Number etc data . 1 2

vipinbeni avatar Sep 15 '14 04:09 vipinbeni

Please help me how can i get Phone Number email etc

vipinbeni avatar Sep 15 '14 04:09 vipinbeni

sorry,you should test msg[3] is lastrecord

airwolf2026 avatar Sep 16 '14 03:09 airwolf2026

Dear Sir . Could you please give some brief in detail

where i am wrong and where to change .

vipinbeni avatar Sep 16 '14 03:09 vipinbeni

Dear Sir . Could you please give some brief in detail

where i am wrong

On Tue, Sep 16, 2014 at 9:05 AM, airwolf2026 [email protected] wrote:

sorry,you should test msg[3] is lastrecord

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-55690912 .

Thanks Vipin Kumar Beniwal

vipinbeni avatar Sep 16 '14 03:09 vipinbeni

sniff the usb message use Bus Hound

SDMessageProcessChanges com.apple.Contacts 3/6/8 com.apple.syncservices.RecordEntityName com.apple.contacts.Phone Number contact 6 type mobile value +86123567 SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey SyncDeviceLinkEntityNamesKey com.apple.contacts.Phone Number

airwolf2026 avatar Sep 16 '14 06:09 airwolf2026

Hi Sir,

i add following to my code array = plist_new_array(); plist_array_append_item(array, plist_new_string("SDMessageProcessChanges")); plist_array_append_item(array, plist_new_string("com.apple.Contacts")); plist_array_append_item(array, plist_new_dict()); plist_array_append_item(array, plist_new_bool(0)); plist_t dict1 = plist_new_dict(); plist_array_append_item(array, dict1); plist_t array22 = plist_new_array(); plist_dict_insert_item(dict1, "SyncDeviceLinkEntityNamesKey", array22); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Phone Number")); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Group")); plist_dict_insert_item(dict1, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0));

  ret = mobilesync_send(client, array);
  plist_free(array);
  array = NULL;

  ret = mobilesync_receive(client, &array);
   if(plist_get_parent(array) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(array) == PLIST_ARRAY)     /* check whether root node is an array  */
                plist_to_xml(array, &xml, &xml_size);
printf("%s\n", xml);

but out put is still same .

< key >15< /key > < dict > < key >com.apple.syncservices.RecordEntityName < /key > < string >com.apple.contacts.Contact< /string > < key >first name< /key > < string >Ratina < key >display as company< /key > < string >person< /string > < /dict > < key >3 < dict > < key >first name< /key > < string >Zulfiqar< /string > < key >company name< /key > < string >Ftftft< /string > < key >last name< /key > < string >Ali< /string > < key >notes< /key > < string >My notes vvvvvvvvvvvvv< /string > < key >birthday< /key > < date/ > < key >display as company< /key > < string >person< /string > < key >com.apple.syncservices.RecordEntityName< /key > < string >com.apple.contacts.Contact< /string >

Dear Sir please tell me how you get these value :

com.apple.syncservices.RecordEntityName com.apple.contacts.Phone Number contact

6

type mobile value +86123567

vipinbeni avatar Sep 16 '14 08:09 vipinbeni

plist_dict_insert_item(dict1, "SyncDeviceLinkEntityNamesKey", array22); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Phone Number")); plist_array_append_item(array22, plist_new_string("com.apple.contacts.Group")); plist_dict_insert_item(dict1, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", >plist_new_bool(0));

don't add these ,these are idevice send to computer

airwolf2026 avatar Sep 16 '14 08:09 airwolf2026

then how can i get phone no my all code is shown to you sir where i am wrong please tell me where i have to change or add something pls help .

vipinbeni avatar Sep 16 '14 08:09 vipinbeni

i know why you can't get more info while(msg!=NULL) { err = mobilesync_receive(client, &msg); //send 'SDMessageAcknowledgeChangesFromDevice' msg = plist_new_array(); plist_array_append_item(msg,plist_new_string("SDMessageAcknowledgeChangesFromDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); err = mobilesync_send(sync_client, msg); if(plist_get_parent(msg) == NULL) /* check whether it's a root node / if(plist_get_node_type(msg) == PLIST_ARRAY) / check whether root node is an array */ plist_to_xml(msg, &xml, &xml_size); printf("%s\n", xml); }

airwolf2026 avatar Sep 16 '14 08:09 airwolf2026

send 'SDMessageAcknowledgeChangesFromDevice' to tell device you had done previous msg,then device can send other info like phonenumbers etc

airwolf2026 avatar Sep 16 '14 08:09 airwolf2026

hi sir i tried it but same out out still i am trying it to rewrite again as money changes has been done after final i will show you my code again .

vipinbeni avatar Sep 16 '14 09:09 vipinbeni

Thanks a lot Sir its working after make some little change THANKS A LOT and expecting help if needed in further implementation of this sync process to my application..

vipinbeni avatar Sep 16 '14 10:09 vipinbeni

hm, there are a lot free software to manager idevice.

airwolf2026 avatar Sep 16 '14 10:09 airwolf2026

k I want to add new contact with all detail to iphone is i am in right direction pls guide me sir..

i am using vc++ in my app

can i also insert contact with this method .

vipinbeni avatar Sep 16 '14 10:09 vipinbeni

yes,you're in rigtht direction reference this http://www.libimobiledevice.org/docs/mobilesync.html to sync changes to iphone

airwolf2026 avatar Sep 17 '14 02:09 airwolf2026

Dear Sir Could you tell me little bit how can i insert i new contact in iphone using this some steps as you tell me in reading contact from iphone

Thanks

On Wed, Sep 17, 2014 at 8:13 AM, airwolf2026 [email protected] wrote:

yes,you're in rigtht direction reference this http://www.libimobiledevice.org/docs/mobilesync.html to sync changes to iphone

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-55842100 .

Thanks Vipin Kumar Beniwal

vipinbeni avatar Sep 17 '14 02:09 vipinbeni

Hi Sir,

i am trying to add new contact using following code but i am not understand how can i do this please help me . where the detail of contact add i don't understand pls help me out sir.

int main1(mobilesync_client_t sync_client) { int count, i, err; plist_t data = NULL; plist_t msg = NULL; plist_t response_t = NULL; char * response; /* Initial handshake / msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("SDMessageSyncDataClassWithDevice")); plist_array_append_item(msg, plist_new_string("com.apple.Contacts")); plist_array_append_item(msg, plist_new_string("---")); plist_array_append_item(msg, plist_new_string("2013-07-29 22-34-00 00")); / plist_array_append_item(msg, plist_new_string("SDSyncTypeSlow")); */ plist_array_append_item(msg, plist_new_uint(106)); plist_array_append_item(msg, plist_new_string("_EmptyParameterString_")); err = mobilesync_send(sync_client, msg); plist_free(msg); msg = NULL; if(err != 0) { printf("mobilesync_send %d, exiting.\n", err);

        return 0;
}
plist_free(msg);
msg = NULL;
err = mobilesync_receive(sync_client, &msg);
if(err != 0)
{
        printf("mobilesync_receive %d, exiting.\n", err);

        return 0;
}
response_t = plist_array_get_item(msg, 0);
plist_get_string_val(response_t, &response);
if(strcmp(response, "SDMessageSyncDataClassWithComputer") != 0)
{

        return 0;
}
msg = plist_new_array();
plist_array_append_item(msg, plist_new_string("SDMessageGetAllRecordsFromDevice"));
plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));
err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;
if(err != 0)
{
        printf("mobilesync_send %d, exiting.\n", err);

        return 0;;
}
char * xml = NULL;
unsigned int xml_size;
err = mobilesync_receive(sync_client, &msg);
if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
    while(msg!=NULL)
{

    plist_free(msg);
    msg = NULL;
    printf("%s\n", xml);
    //send 'SDMessageAcknowledgeChangesFromDevice'
    msg = plist_new_array();
    plist_array_append_item(msg,plist_new_string("SDMessageAcknowledgeChangesFromDevice"));
    plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));
    err = mobilesync_send(sync_client, msg);
    plist_free(msg);
    msg = NULL;


    err = mobilesync_receive(sync_client, &msg);
    if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
        xml_size=0;

    //
}

//=======================new change to add new contact ===========================// msg = plist_new_array(); plist_array_append_item(msg, plist_new_string("DLMessagePing")); plist_array_append_item(msg, plist_new_string("Preparing to get changes for device"));

err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;

msg = plist_new_array();
plist_array_append_item(msg, plist_new_string("SDMessageProcessChanges"));
plist_array_append_item(msg, plist_new_string("com.apple.Contacts"));

plist_array_append_item(msg, plist_new_dict());
plist_array_append_item(msg, plist_new_string("vipin"));
plist_array_append_item(msg, plist_new_bool(1));

plist_t dict = plist_new_dict();
plist_array_append_item(msg, dict);
plist_t array2 = plist_new_array();
plist_dict_insert_item(dict, "SyncDeviceLinkEntityNamesKey", array2);
plist_array_append_item(array2, plist_new_string("com.apple.contacts.Contact"));
plist_array_append_item(array2, plist_new_string("com.apple.contacts.Group"));
plist_dict_insert_item(dict, "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey", plist_new_bool(0));

err = mobilesync_send(sync_client, msg);
plist_free(msg);
msg = NULL;

err = mobilesync_receive(sync_client, &msg);

if(plist_get_parent(msg) == NULL) /* check whether it's a root node */
    if(plist_get_node_type(msg) == PLIST_ARRAY) /* check whether root node is an array */
    plist_to_xml(msg, &xml, &xml_size);
    printf("%s\n", xml);
    xml=NULL;
plist_free(msg);
msg = NULL;
    //=======================================================//
if(err != 0)
{
        printf("mobilesync_receive %d, exiting.\n", err);

        return 0;
}
/* both checks are voluntary */
if(plist_get_parent(msg) == NULL)                       /* check whether it's a root node       */
        if(plist_get_node_type(msg) == PLIST_ARRAY)     /* check whether root node is an array  */
                plist_to_xml(msg, &xml, &xml_size);
printf("%s\n", xml);

return 0;
}

where i add details of contact and how it insert to iphone .

vipinbeni avatar Sep 18 '14 09:09 vipinbeni

change the line 'plist_array_append_item(msg, plist_new_string("vipin"));' to plist_t contactMainInfoDict =plist_new_dict(); plist_dict_insert_item(contactMainInfoDict , "first name", plist_new_string("FirstName")); plist_dict_insert_item(contactMainInfoDict , "last name", plist_new_string("LastName")); blabla...like device send plist format to pc;

plist_array_append_item(msg,contactMainInfoDict );

may this help you ,sorry for my poor english.

airwolf2026 avatar Sep 18 '14 09:09 airwolf2026

K thanks Sir i will try it and reply you

vipinbeni avatar Sep 18 '14 11:09 vipinbeni

Hi Sir

@storoj please Help me as i am waiting for your reply pls help me sir .

On Fri, Sep 19, 2014 at 2:35 PM, vipin beniwal < [email protected]> wrote:

Hi Sir , contact is not added after changing this

On Thu, Sep 18, 2014 at 3:02 PM, airwolf2026 [email protected] wrote:

change the line 'plist_array_append_item(msg, plist_new_string("vipin"));' to plist_t contactMainInfoDict =plist_new_dict(); plist_dict_insert_item(contactMainInfoDict , "first name", plist_new_string("FirstName")); plist_dict_insert_item(contactMainInfoDict , "last name", plist_new_string("LastName")); blabla...like device send plist format to pc;

plist_array_append_item(msg,contactMainInfoDict );

may this help you ,sorry for my poor english.

— Reply to this email directly or view it on GitHub https://github.com/storoj/libimobiledevice-win32/issues/18#issuecomment-56015788 .

Thanks Vipin Kumar Beniwal

Thanks Vipin Kumar Beniwal

vipinbeni avatar Sep 22 '14 03:09 vipinbeni

before send contact msg to device ,send

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>DLMessagePing</string>
    <string>com.apple.Contacts</string>
</array>
</plist>

then send the contact msg, in your case ,you miss the contact id

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{7F2CEA11-BF50-4288-8A24-585D7C1FA47A}</key>
        <dict>
            <key>birthday</key>
            <date>2014-09-22T00:00:00Z</date>
            <key>com.apple.syncservices.RecordEntityName</key>
            <string>com.apple.contacts.Contact</string>
            <key>company name</key>
            <string>company</string>
            <key>department</key>
            <string>department</string>
            <key>display as company</key>
            <string>person</string>
            <key>first name</key>
            <string>name</string>
            <key>job title</key>
            <string>jobs</string>
            <key>last name</key>
            <string>test</string>
        </dict>
    </dict>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Contact</string>
            <string>com.apple.contacts.Group</string>
        </array>
    </dict>
</array>
</plist>

after send the msg, device will send you the new id on device ,like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageRemapRecordIdentifiers</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{7F2CEA11-BF50-4288-8A24-585D7C1FA47A}</key>
        <string>11</string>
    </dict>
</array>
</plist>

then ,you can send phonenumbers, email etc to device ,in case of phoneNumbers:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{A63CF3AD-B01A-48A8-BB5B-598CE69394CE}</key>
        <dict>
            <key>com.apple.syncservices.RecordEntityName</key>
            <string>com.apple.contacts.Phone Number</string>
            <key>contact</key>
            <array>
                <string>11</string>
            </array>
            <key>type</key>
            <string>mobile</string>
            <key>value</key>
            <string>8613599998888</string>
        </dict>
    </dict>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Phone Number</string>
        </array>
    </dict>
</array>
</plist>

like main contact info,after received phoneNumbers,device will send you the new id base on your phoneNumber id.

<plist version="1.0">
<array>
    <string>SDMessageRemapRecordIdentifiers</string>
    <string>com.apple.Contacts</string>
    <dict>
        <key>{A63CF3AD-B01A-48A8-BB5B-598CE69394CE}</key>
        <string>3/11/0</string>
    </dict>
</array>
</plist>

airwolf2026 avatar Sep 22 '14 03:09 airwolf2026

k Thanks Sir I will try this and get back to you Thanks a lot.

vipinbeni avatar Sep 22 '14 03:09 vipinbeni

Dear Sir all is going in the same way but contact is not shown and each time adding same contact id is coming , phone no out put is also same as you describe but contact is not added to iphone .

new4

new3

where is i am doing wrong pls help me sir

vipinbeni avatar Sep 22 '14 05:09 vipinbeni

you should send other infos to device ,like related name,email,dates etc.

<plist version="1.0">
<array>
    <string>SDMessageProcessChanges</string>
    <string>com.apple.Contacts</string>
    <dict/>
    <true/>
    <dict>
        <key>SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey</key>
        <true/>
        <key>SyncDeviceLinkEntityNamesKey</key>
        <array>
            <string>com.apple.contacts.Related Name</string>
        </array>
    </dict>
</array>
</plist> 

in final,send

<plist version="1.0">
<array>
    <string>SDMessageFinishSessionOnDevice</string>
    <string>com.apple.Contacts</string>
</array>
</plist>

you should download a free ios tool ,then use busHound to sniffer the packet,when add a new contact.

airwolf2026 avatar Sep 22 '14 06:09 airwolf2026

Dear Sir,

One More Query to you i am running libimobiledevice-win32 successfully in debug configuration but in release mode it show me lot of error how can i build it in release mode . I am getting error like

Touching "Release\libcnary.unsuccessfulbuild". 1>ClCompile: 1> cnary.c 1>cnary.c(30): error C2275: 'node_t' : illegal use of this type as an expression 1> D:\contact sync\libimobiledevice-win32-master-1\libcnary\include\node.h(54) : see declaration of 'node_t' 1>cnary.c(30): error C2065: 'root' : undeclared identifier

ClCompile: 2> libusbmuxd.c 1> base64.c 1>src\base64.c(49): error C2275: 'size_t' : illegal use of this type as an expression 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(29) : see declaration of 'size_t' 1>src\base64.c(49): error C2146: syntax error : missing ';' before identifier 'outlen

vipinbeni avatar Sep 24 '14 05:09 vipinbeni

sorry, i didn't build the project in release.

airwolf2026 avatar Sep 24 '14 05:09 airwolf2026