简体   繁体   English

在Windows Phone 8.1 RT App中启动2个SMS撰写任务

[英]Launch 2 SMS Compose tasks in Windows Phone 8.1 RT App

I have a button in my Windows Phone 8.1 RT app. 我的Windows Phone 8.1 RT应用程序中有一个按钮。 When the user clicks the button, 2 SMS are supposed to be sent to two different users. 当用户单击按钮时,应该将2条SMS发送给两个不同的用户。

I can launch one SMS Task using the following code 我可以使用以下代码启动一个SMS任务

var message = new ChatMessage();
message.Recipients.Add("1231233");
message.Body = "This is a text message from an app!";
await ChatMessageManager.ShowComposeSmsMessageAsync(message);

But when I do this multiple times, the app crashes. 但是,当我多次执行此操作时,应用程序崩溃。 The Task complete event fires on task launch, is there a way to know if the user has returned to the app after sending SMS so the next one can be fired? Task complete事件在任务启动时触发,是否有办法知道用户在发送SMS后是否已返回到应用程序,以便可以触发下一个?

If the ShowComposeSmsMessageAsync is anything like the MessageDialog.ShowAsync method, which seems true as both return IAsyncInfo objects (..Action/..Operation is different, but the async part is important for us), this problem could be solved like the problem of showing multiple message dialogs. 如果ShowComposeSmsMessageAsync类似于MessageDialog.ShowAsync方法,当两者都返回IAsyncInfo对象(..Action / .. Operation不同,但异步部分对我们很重要)时,它似乎是正确的,则可以像解决问题一样解决此问题。显示多个消息对话框。 A quick search yielded this question, with multiple correct solutions: How to allow for multiple popups at once in WinRT? 快速搜索产生了这个问题,并提出了多种正确的解决方案: 如何在WinRT中一次允许多个弹出窗口?

If the above doesn't work, you could - for example - subscribe to the VisibilityChanged event of the app Window ( https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.window.aspx ), as it should provide you with an event about the user returning from the sms task. 如果上述方法不起作用,则可以-例如-订阅应用程序WindowVisibilityChanged事件( https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.ui.xaml。 window.aspx ),因为它应该为您提供有关用户从sms任务返回的事件。

So basically 1. subscibe to event, 2. send 1st sms, 3. wait for event, 4. send 2nd sms. 所以基本上1.订阅事件,2.发送第一个短信,3.等待事件,4.发送第二个短信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM