1

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.

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);

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?

Omkar Khair
  • 1,364
  • 2
  • 17
  • 40

1 Answers1

0

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?

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.

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

Community
  • 1
  • 1
Tamás Deme
  • 2,194
  • 2
  • 13
  • 31
  • I think the `OnNavigatedTo` event works better. Setting a flag in there does the job. Wish it was simpler to do such things on Windows Phone. – Omkar Khair Apr 27 '15 at 06:34