(1)聯系人(Manifest 獲取權限)
1)獲取聯系人
獲取聯系人的方式有兩種
A. ContactPicker
ContactPicker 也就是直接打開一個系統的選擇聯系人界面,讓用戶選擇,可設置單選或多選:
var contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); //Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactsAsync(); Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactAsync(); if( contact != null ) { MessageDialog dialog = new MessageDialog(string.Format("Phone Number: {0}", contact.Phones.First().Number), contact.DisplayName); await dialog.ShowAsync(); }
必須設置唯一的一個 ContactFieldType。
B. ContactManager
可通過 ContactManager API 直接搜索某聯系人:
ContactStore contactStore = await ContactManager.RequestStoreAsync(); var list = await contactStore.FindContactsAsync(searchTextBox.Text.Trim());
獲取的聯系人列表為只讀的。
2)與聯系人聯系
可直接向聯系人撥打電話、發送短信、發送郵件:
PhoneCallManager.ShowPhoneCallUI("15911111111", "Some"); ChatMessage message = new ChatMessage(); message.Recipients.Add("15911111111"); message.Body = "Test."; await ChatMessageManager.ShowComposeSmsMessageAsync(message); EmailMessage email = new EmailMessage(); email.To.Add(new EmailRecipient("aaa@qq.com")); email.Body = "Test."; await EmailManager.ShowComposeNewEmailAsync(email);
(2)日歷
1)直接打開系統的日歷應用
比如打開日歷主界面:
await AppointmentManager.ShowTimeFrameAsync(DateTimeOffset.Now, TimeSpan.FromHours(1));
2)API 方式
比如新建一個日歷事件:
Appointment appointment = new Appointment(); appointment.Subject = ""; appointment.StartTime = DateTimeOffset.Now; //... await AppointmentManager.ShowAddAppointmentAsync(appointment, new Rect());
更多 API :鏈接