ProximityDevice.PublishUriMessage | publishUriMessage methods

Publishes a Uniform Resource Identifier (URI) to a proximate device.

Overload list

PublishUriMessage(Uri) Publishes a Uniform Resource Identifier (URI) to a proximate device.
PublishUriMessage(Uri, MessageTransmittedHandler) Publishes a Uniform Resource Identifier (URI) to a proximate device. The specified handler is called when the message has been transmitted.


Only one URI can be published at a time for each proximity device.

You can stop publishing a URI by passing the publication ID returned by the PublishUriMessage method to the StopPublishingMessage method.

Unlike the other publish methods for a proximity device, URI publishing is handled by the default protocol handler for the URI. A subscription to a URI message publication is not required. You can receive URI messages by registering a default handler for a URI protocol such as the HTTP protocol.

The PackageFamilyName value of the sending application is automatically sent along with the URI. If no handler is registered for the protocol of a URI, the PackageFamilyName value of the sending application is used to direct the receiving application to the application store.

You can use the PublishMessage method to publish a text message to a proximate computer. You can use the PublishBinaryMessage method to publish non-text messages or messages that conform to the NDEF messaging standard.


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.


Private proximityDevice As Windows.Networking.Proximity.ProximityDevice

Public Sub New()

End Sub

Private Sub initializeProximitySample()
    proximityDevice = Windows.Networking.Proximity.ProximityDevice.GetDefault()

    If proximityDevice Is Nothing Then
        WriteMessageText("Failed to initialized proximity device." & vbCrLf &
                         "Your device may not have proximity hardware.")
    End If
End Sub

' Write a message to MessageBlock on the UI thread.
Private Async Sub WriteMessageText(message As String, Optional overwrite As Boolean = False)
    Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                If overwrite Then
                    MessageBlock.Text = message
                    MessageBlock.Text &= message
                End If
            End Sub)
End Sub

Private publishedUriId As Long = -1

Private Sub PublishUriButton_Click(sender As Object, e As RoutedEventArgs)
    ' Stop publishing the current message.
    If publishedUriId <> -1 Then
    End If

    publishedUriId =
        proximityDevice.PublishUriMessage(New Uri("http:'"))
End Sub

Private Sub StopPublishingUriButton_Click()
End Sub


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8


Windows::Networking::Proximity [C++]



See also

Proximity and Tapping (JavaScript)
Proximity and Tapping (C#/VB/C++)
Proximity sample



© 2015 Microsoft