private async void ProcessEContactClick(EContactItem selectedItem) { string content = string.Format("Call or message {0}?\nPress back to cancel.", selectedItem.Name); string title = "Information"; string[] cmdString = new string[] { "call", "message" }; MessageDialog md = new MessageDialog(content, title); md.Commands.Add(new UICommand(cmdString[0])); md.Commands.Add(new UICommand(cmdString[1])); IUICommand result = await md.ShowAsync(); if (result == null) { return; } string resultString = result.Label; if (resultString == cmdString[0]) { // Process call Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(selectedItem.Contact, selectedItem.Name); } else if (resultString == cmdString[1]) { // Process message Windows.ApplicationModel.Chat.ChatMessage chatMsg = new Windows.ApplicationModel.Chat.ChatMessage(); chatMsg.Recipients.Add(selectedItem.Contact); chatMsg.Body = ""; await ChatMessageManager.ShowComposeSmsMessageAsync(chatMsg); } }
/// <summary> /// 发送短信 /// </summary> /// <param name="toPhoneNumber">目标电话号码</param> /// <param name="body">短信主体</param> /// <returns></returns> public static async Task ComposeSms(string toPhoneNumber, string body) { var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage(); chatMessage.Body = body; chatMessage.Recipients.Add(toPhoneNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); }
private async void ProcessEContactClick(EContactItem selectedItem) { string content = string.Format("Call or message {0}?\nPress back to cancel.", selectedItem.Name); string title = "Information"; string[] cmdString = new string[] { "call", "message" }; MessageDialog md = new MessageDialog(content, title); md.Commands.Add(new UICommand(cmdString[0])); md.Commands.Add(new UICommand(cmdString[1])); IUICommand result = await md.ShowAsync(); if (result == null) return; string resultString = result.Label; if (resultString == cmdString[0]) { // Process call Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(selectedItem.Contact, selectedItem.Name); } else if (resultString == cmdString[1]) { // Process message Windows.ApplicationModel.Chat.ChatMessage chatMsg = new Windows.ApplicationModel.Chat.ChatMessage(); chatMsg.Recipients.Add(selectedItem.Contact); chatMsg.Body = ""; await ChatMessageManager.ShowComposeSmsMessageAsync(chatMsg); } }