private async void SendContactExecute() { var picker = new ContactPicker(); picker.SelectionMode = ContactSelectionMode.Fields; picker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var picked = await picker.PickContactAsync(); if (picked != null) { TdWindows.Contact contact = null; var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite); var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); if (store != null && annotationStore != null) { var full = await store.GetContactAsync(picked.Id); if (full != null) { var annotations = await annotationStore.FindAnnotationsForContactAsync(full); var first = annotations.FirstOrDefault(); if (first != null) { var remote = first.RemoteId; if (int.TryParse(remote.Substring(1), out int userId)) { var user = ProtoService.GetUser(userId); if (user != null) { contact = new TdWindows.Contact(user.PhoneNumber, user.FirstName, user.LanguageCode, user.Id); } } } //contact = full; } } if (contact == null) { var phone = picked.Phones.FirstOrDefault(); if (phone == null) { return; } contact = new TdWindows.Contact(phone.Number, picked.FirstName, picked.LastName, 0); } if (contact != null) { await SendContactAsync(contact); } } }
public Task <BaseObject> SendContactAsync(TdWindows.Contact contact) { return(SendMessageAsync(0, new InputMessageContact(contact))); }