在 Windows Phone 8.1 RT 应用程序中启动 2 个 SMS Compose 任务 [英] Launch 2 SMS Compose tasks in Windows Phone 8.1 RT App

查看:19
本文介绍了在 Windows Phone 8.1 RT 应用程序中启动 2 个 SMS Compose 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Windows Phone 8.1 RT 应用中有一个按钮.当用户点击按钮时,应该向两个不同的用户发送 2 条短信.

I have a button in my Windows Phone 8.1 RT app. When the user clicks the button, 2 SMS are supposed to be sent to two different users.

我可以使用以下代码启动一个 SMS 任务

I can launch one SMS Task using the following code

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

但是当我多次这样做时,应用程序崩溃了.任务完成事件在任务启动时触发,有没有办法知道用户在发送 SMS 后是否已返回应用程序,以便触发下一个?

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?

推荐答案

如果 ShowComposeSmsMessageAsync 类似于 MessageDialog.ShowAsync 方法,这似乎是正确的,因为两者都返回 IAsyncInfo对象(..Action/..Operation 不同,但异步部分对我们很重要),这个问题可以像显示多个消息对话框的问题一样解决.快速搜索产生了这个问题,有多个正确的解决方案:如何在 WinRT 中同时允许多个弹出窗口?

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. A quick search yielded this question, with multiple correct solutions: How to allow for multiple popups at once in WinRT?

如果上述方法不起作用,您可以 - 例如 - 订阅应用 WindowVisibilityChanged 事件(https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.window.aspx),因为它应该为您提供有关用户从 sms 任务返回的事件.

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.

所以基本上 1. 订阅事件,2. 发送第一条短信,3. 等待事件,4. 发送第二条短信.

So basically 1. subscibe to event, 2. send 1st sms, 3. wait for event, 4. send 2nd sms.

这篇关于在 Windows Phone 8.1 RT 应用程序中启动 2 个 SMS Compose 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆