-api-id | -api-type | -api-device-family-note |
---|---|---|
M:Windows.Networking.Proximity.ProximityDevice.PublishMessage(System.String,System.String,Windows.Networking.Proximity.MessageTransmittedHandler) |
winrt method |
xbox |
Publishes a message to subscribers of the specified message type. The specified handler is called when the message has been transmitted.
The type of message to deliver to subscribers.
The message to deliver to subscribers.
The handler to call when the message has been transmitted.
A unique publication ID for the published message.
You can subscribe to published messages by using the SubscribeForMessage method.
Messages continue to be published until the StopPublishingMessage method is called or the ProximityDevice object is released.
Messages are delivered to all applications that have subscribed to the message type (as indicated by the messageType parameter). Message type values are case-sensitive strings that consist of two parts: the protocol and the subtype. The protocol is first, followed by a dot (.) and then the subtype. For the PublishMessage method, the protocol must always be "Windows.". The subtype is a string of alphanumeric characters and the following additional characters: . ( ) + , - : = @ ; $ _ ! * '. The subtype cannot exceed a length of 250 characters.
To publish messages by using another message type, like "WindowsMime." or "NDEF:WriteTag", you must use the PublishBinaryMessage method.
You can use the PublishUriMessage method to publish a Uniform Resource Identifier (URI) to a proximate computer.
Messages are converted to UTF-8 characters before they're transmitted.
For UWP apps, publications and subscriptions are active only if the calling app is in the foreground.
Important
The proximity APIs do not provide authentication, encryption, or message integrity. Do not use proximity to exchange user sensitive information such as passwords, financial data, text messages, email, photographs, or government id numbers.
[!code-csharpPublishSubscribe2]
[!code-vbPublishSubscribe2]
PublishMessage(String, String), PublishBinaryMessage, PublishUriMessage, StopPublishingMessage, Proximity and Tapping (C#/VB/C++), Proximity sample
proximity ID_CAP_PROXIMITY [Windows Phone], ID_CAP_PROXIMITY [Windows Phone]