public async Task SendFriendLinkViaSms() { IsLoading = true; var result = await ChatMessageManager.GetTransportsAsync(); if (!result.Any()) { IsLoading = false; await ResultChecker.SendMessageDialogAsync(_loader.GetString("NoSMS/Text"), false); return; } var link = await CreateFriendLink(); if (!string.IsNullOrEmpty(link)) { var chat = new ChatMessage { Subject = _loader.GetString("FriendRequestBody/Text"), Body = string.Format("{0} {1}", _loader.GetString("FriendRequestBody/Text"), link) }; await ChatMessageManager.ShowComposeSmsMessageAsync(chat); } IsLoading = false; }
/// <summary> /// Shows the Messaging application, using the specified recipient list and message body. /// </summary> /// <param name="recipient">The recipient list for the new SMS message.</param> /// <param name="body">The body text of the new SMS message.</param> /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns> public virtual Task ShowAsync(string recipient, string body) { #if WINDOWS_PHONE || WINDOWS_PHONE_81 new SmsComposeTask() { To = recipient, Body = body }.Show(); return(Task.FromResult(0)); #elif WINDOWS_PHONE_APP || WINDOWS_UWP var chatMessage = new ChatMessage { Body = body }; if (!string.IsNullOrEmpty(recipient)) { chatMessage.Recipients.Add(recipient); } return(ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage).AsTask()); #else var smsUri = new UriBuilder("sms:") .SetPath(recipient) .AppendQueryParameterIfValueNotEmpty("body", body) .Uri; return(Launcher.LaunchUriAsync(smsUri).AsTask()); #endif }
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> /// Shows the Messaging application, using the specified recipient list and message body. /// </summary> /// <param name="recipient">The recipient list for the new SMS message.</param> /// <param name="body">The body text of the new SMS message.</param> /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns> public async Task ShowAsync(string recipient, string body) { #if WINDOWS_PHONE new SmsComposeTask() { To = recipient, Body = body }.Show(); await Task.FromResult(0); #elif WINDOWS_PHONE_APP var chatMessage = new ChatMessage { Body = body }; chatMessage.Recipients.Add(recipient); await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); #else var smsUrl = "sms:" + Uri.EscapeDataString(recipient); if (!string.IsNullOrEmpty(body)) { smsUrl += "?body=" + Uri.EscapeDataString(body); } await Launcher.LaunchUriAsync(new Uri(smsUrl, UriKind.Absolute)); #endif }
private async void btFinalizaPedido_Click(object sender, RoutedEventArgs e) { ChatMessage sms = new ChatMessage(); sms.Body = String.Format("Pedido {0} concluído com sucesso", novoPedido); sms.Recipients.Add(((Cliente)listaClientes.SelectedItem).Telefone); await ChatMessageManager.ShowComposeSmsMessageAsync(sms); }
private async void btn_send_Click(object sender, RoutedEventArgs e) { var sms = new ChatMessage(); sms.Body = lv_results.SelectedItem as string; await ChatMessageManager.ShowComposeSmsMessageAsync(sms); }
private async void Button_Click(object sender, RoutedEventArgs e) { var message = new ChatMessage(); message.Recipients.Add("512-363-3198"); message.Body = "This is a text message from an app!"; await ChatMessageManager.ShowComposeSmsMessageAsync(message); }
/// <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); }
public async void SendSMS(string body, string phoneNumber) { var chat = new ChatMessage { Body = body }; chat.Recipients.Add(phoneNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(chat); }
private async void btnChat_Click(object sender, RoutedEventArgs e) { var chat = new ChatMessage( ); chat.Body = "Hello there"; chat.Recipients.Add("123456789"); await ChatMessageManager.ShowComposeSmsMessageAsync(chat); }
/// <summary> /// Sends the SMS. /// </summary> /// <param name="to">To.</param> /// <param name="body">The body.</param> public async void SendSMS(string to, string body) { var msg = new ChatMessage(); msg.Recipients.Add(to); msg.Body = body; await ChatMessageManager.ShowComposeSmsMessageAsync(msg); }
public void SendSMS(string body, string phoneNumber) { var chatMessage = new ChatMessage { Body = body }; chatMessage.Recipients.Add(phoneNumber); Task.Run(() => ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage)); }
protected override async void OnActivated(IActivatedEventArgs args) { DataPackage dataPackage = new DataPackage(); try { if (args.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri var sms = new ChatMessage(); uridata = WebUtility.HtmlDecode(eventArgs.Uri.OriginalString); query = WebUtility.HtmlDecode(eventArgs.Uri.Query); if (!String.IsNullOrEmpty(query)) // Has content { // Try to copy number and content between ? and = // Try to get number sms.Recipients.Add(getbetween(uridata, ":", "?")); sms.Body = getbetween(uridata, "="); p.rec = getbetween(uridata, ":", "?"); p.msg = (uridata.Substring(uridata.IndexOf("="))).Replace("=", ""); } else { string n = (uridata.Substring(uridata.IndexOf(":"))).Replace(":", ""); if (Regex.Match(n, @"^[0-9]+(-[0-9]+)+$").Success) { // Just copy number sms.Recipients.Add(n); p.rec = n; p.msg = ""; } else { sms.Body = n; p.rec = ""; p.msg = n; } } dataPackage.RequestedOperation = DataPackageOperation.Copy; dataPackage.SetText(p.rec + " " + p.msg); Clipboard.SetContent(dataPackage); await ChatMessageManager.ShowComposeSmsMessageAsync(sms); } } catch { } }
public void SendSOSSMS(string message, string mobileNumber) { Task.Run(async() => { var chatMessage = new ChatMessage { Body = message, }; chatMessage.Recipients.Add(mobileNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); }); }
public virtual async Task ShowAsync(string recipient, string body) { var chatMessage = new ChatMessage { Body = body }; if (!string.IsNullOrEmpty(recipient)) { chatMessage.Recipients.Add(recipient); } await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); }
//发短信 public static async void MsgFunc() { try { var chatMessage = new ChatMessage(); chatMessage.Recipients.Add("18317722768"); chatMessage.Body = "hello world"; await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
/// <summary> /// Method invoked when the user clicks on Scrivi messaggio button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void AppBarButton_Tapped_3(object sender, TappedRoutedEventArgs e) { FrameworkElement element = (FrameworkElement)sender; Message message = (Message)element.DataContext; try { ChatMessage chat = new ChatMessage(); chat.Recipients.Add(message.Sender); await ChatMessageManager.ShowComposeSmsMessageAsync(chat); } catch (Exception ex) { ShellPage.Current.HandleExceptionNotification(ex); } }
public virtual async Task ComposeSMS(string recipient, string message = null) { if (!CanComposeSMS) { throw new FeatureNotAvailableException(); } var sms = new ChatMessage { Recipients = { recipient }, Body = message }; await ChatMessageManager.ShowComposeSmsMessageAsync(sms); }
static Task PlatformComposeAsync(SmsMessage message) { var chat = new ChatMessage(); if (!string.IsNullOrWhiteSpace(message?.Body)) { chat.Body = message.Body; } if (!string.IsNullOrWhiteSpace(message?.Recipient)) { chat.Recipients.Add(message.Recipient); } return(ChatMessageManager.ShowComposeSmsMessageAsync(chat).AsTask()); }
private async void ComposeMessage_Click(object sender, RoutedEventArgs e) { //Check if the current device has any transports that can deliver //a text message. Note that calling this API requires the chat //capability (see Package.appxmanifest) var transports = await ChatMessageManager.GetTransportsAsync(); //If there are transports available, call ShowComposeSmsMessageAsync if (transports.Any()) { var textMessage = new ChatMessage(); textMessage.Body = Message.Text; await ChatMessageManager.ShowComposeSmsMessageAsync(textMessage); } }
public Task ComposeAsync(SmsMessage message) { var chat = new ChatMessage(); if (!string.IsNullOrWhiteSpace(message?.Body)) { chat.Body = message.Body; } foreach (var recipient in message?.Recipients) { chat.Recipients.Add(recipient); } return(ChatMessageManager.ShowComposeSmsMessageAsync(chat).AsTask()); }
private async void TextExecute() { var msg = new ChatMessage { Body = $"Contacting you in regards to your post on Findier: \"{Post.Title}\"" }; msg.Recipients.Add(Post.PhoneNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(msg); _insightsService.TrackEvent("ContactSms", new Dictionary <string, string> { { "PostId", Post.Id } }); }
internal static async Task PlatformComposeAsync(SMS message) { try { var sms = new ChatMessage { Body = message.MessageText, MessageKind = ChatMessageKind.Standard, MessageOperatorKind = ChatMessageOperatorKind.Sms }; foreach (var receiver in message.Receiver) { sms.Recipients.Add(receiver); } await ChatMessageManager.ShowComposeSmsMessageAsync(sms); } catch (Exception ex) { throw new InvalidOperationException("SMS sending failed. It is possible that your device does not support SMS.", ex); } }
public void SendSms(string recipient = null, string message = null) { message = message ?? string.Empty; if (CanSendSms) { var msg = new ChatMessage { Body = message }; if (!string.IsNullOrWhiteSpace(recipient)) { msg.Recipients.Add(recipient); } #pragma warning disable 4014 ChatMessageManager.ShowComposeSmsMessageAsync(msg); #pragma warning restore 4014 } }
public async void Send(string phoneNumber, string messageBody, StorageFile attachmentFile, string mimeType) { var chat = new ChatMessage { Body = messageBody }; if (attachmentFile != null) { var stream = RandomAccessStreamReference.CreateFromFile(attachmentFile); var attachment = new ChatMessageAttachment(mimeType, stream); chat.Attachments.Add(attachment); } chat.Recipients.Add(phoneNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(chat); }
public static Task ComposeAsync(SmsMessage message) { if (!IsComposeSupported) { throw new FeatureNotSupportedException(); } var chat = new ChatMessage(); if (!string.IsNullOrWhiteSpace(message?.Body)) { chat.Body = message.Body; } if (!string.IsNullOrWhiteSpace(message?.Recipient)) { chat.Recipients.Add(message.Recipient); } return(ChatMessageManager.ShowComposeSmsMessageAsync(chat).AsTask()); }
public void SendSms(string recipient, string message) { if (string.IsNullOrWhiteSpace(message)) { throw new ArgumentNullException("message"); } if (CanSendSms) { var msg = new ChatMessage { Body = message }; if (!string.IsNullOrWhiteSpace(recipient)) { msg.Recipients.Add(recipient); } ChatMessageManager.ShowComposeSmsMessageAsync(msg); } }
private async void AddFriendViaSMS_OnClick(object sender, RoutedEventArgs e) { GeneralProgressBar.Visibility = Visibility.Visible; var friendManager = new FriendManager(); FriendTokenEntity tokenEntity = await friendManager.GetFriendLink(App.UserAccountEntity); if (tokenEntity == null) { GeneralProgressBar.Visibility = Visibility.Collapsed; return; } ResourceLoader resourceLoader = ResourceLoader.GetForCurrentView(); string subject = resourceLoader.GetString("AddFriendSubject/Text"); var chatMessage = new ChatMessage { Body = string.Concat(subject, Environment.NewLine, tokenEntity.Token) }; await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); GeneralProgressBar.Visibility = Visibility.Collapsed; }
/// <summary> /// Shows the Messaging application, using the specified recipient list and message body. /// </summary> /// <param name="recipient">The recipient list for the new SMS message.</param> /// <param name="body">The body text of the new SMS message.</param> public void Show(string recipient, string body) { #if WINDOWS_PHONE new SmsComposeTask() { To = recipient, Body = body }.Show(); #elif WINDOWS_PHONE_APP var chatMessage = new ChatMessage { Body = body }; chatMessage.Recipients.Add(recipient); ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage); #else throw new NotSupportedException("This method is not supported in Windows Store Apps"); #endif }
private async Task SendAsync(string toNumber, string message) { if (toNumber.IsBadFormat()) { throw new System.FormatException("Incorrect argument: toNumber !"); } if (message.IsBadFormat()) { throw new System.FormatException("Incorrect argument: toNumber !"); } var smsMessage = new ChatMessage() { Body = message }; smsMessage.Recipients.Add(toNumber); await ChatMessageManager.ShowComposeSmsMessageAsync(smsMessage); }