Send chat message

2019-06-24 04:25发布

问题:

I have this code:

var msg = new ChatMessage();
msg.Body = "Test";
msg.Recipients.Add("number");

var cms = await ChatMessageManager.RequestStoreAsync();
await cms.SendMessageAsync(msg);

and I have a problem with the await part of code above. I get exception:

Access is denied.

In capabilities within appxmanifest I have selected:

Chat Message Access

(I tried select all, but It didn't work). I cannot find any sample and requirements that must be met.

Thanks for your help.

回答1:

If you take a look at MSDN you will see that:

This API is not available to all Windows/Windows Phone apps. Unless your developer account is specially provisioned by Microsoft, calls to these APIs will fail at runtime.