public static void SyncWaContacts(string username, string password) { Contact[] contacts = ContactStore.GetAllContacts(); List <string> input = new List <string>(); foreach (Contact c in contacts) { input.Add(c.jid.Split('@').First()); } ContactSync s = new ContactSync(username, password); try { ContactSyncResult[] res = s.Sync(input.ToArray()); if (res != null) { foreach (ContactSyncResult r in res) { if (r.w == 1) { string jid = r.n + "@s.whatsapp.net"; Contact con = ContactStore.GetContactByJid(jid); if (con != null && con.status != r.s) { //update status if changed con.status = r.s; ContactStore.UpdateStatus(con); } } else { //delete Contact con = ContactStore.GetContactByJid(r.n + "@s.whatsapp.net"); if (con != null) { ContactStore.DeleteContact(con); } } } } } catch (Exception) { } }