What is proximity?

Proximity is a development API which provides support to the connection between devices which are a short distance apart. In a few words, we use Proximity to develop NFC applications on the Windows Phone and it is with that array of classes that we will work. We can use proximity to transfer a photograph between two cell phones with just a tap or initiate a match of a multiplayer game between two friends which are next to each other. The proximity provides support to the Windows and Windows Phone systems as from the 8.0 version.

When the tap is successfully performed between devices, a communication socket is established, which may be by Wi-Fi (TCP/IP) or Bluetooth - the proximity determines the connection which will be established through the values of the standard PeerFinder.AllowBluetooth and PeerFinder.AllowInfrastructure. Normally, that connection is established via Bluetooth; for the use of the Wi-Fi, it is necessary for the two devices to be within the same infrastructure network, with the absence of conflicts of IP or Firewalls. As from the Windows 8.1 it will be possible to use the Wi-Fi Direct; for now, in the 8.0, the support is not provided. It is recommended to inform, in your application to the user, whether the Bluetooth is active in the device. For that purpose, you may use a MessageBox showing the notification message.

The proximity is only able to perform in the active application; when the application goes to Background (answer call, message, another application) all of the messages of the proximity are suspended; there are no background activities, which means that it is not possible to store a request and execute it when the application is back to active; all of the publications will be summarized. What is possible to maintain in background are the Wi-Fi and Bluetooth connections between the devices. To save specific information of the application, we indicate the use of tombstone which will save important information in the event of changes in the status of the application. As a standard, the socket established between the devices is unprotected; should you require a higher degree of safety in your communication, then we indicate the use of encryption; for that, you may use the value of the SessionKey established in the connection as a safety key and apply some algorithm which will be protected by the key and accessed only by the devices. Source code here

We may use the proximity on the Windows Phone to Connect devices, acquire content or exchange digital objects; as examples:
  • Connect Devices – We have the Tap + Shoot Together, which initiates a connection between two devices to shoot photographs together; after the tap a Bluetooth or Wi-Fi connection is initiated between the devices.
  • Acquire Content – To perform a tap on a poster of a motion picture and receive an application of the film, a teaser or a promotional coupon for the premiere of the film in the movie theater.
  • Exchange of Digital Objects – Upon the tapping of cell phones, pass one’s business card to everyone in the meeting room.

See a number of classes of the Proximity and a brief description:

Class Description
PeerFinder Through the PeerFinder it is possible to find other devices nearby and initiate a connection via socket between them.
ProximityDevice Makes the communication possible between devices that are next to each other (3-4 cm) and make the exchange of a upload during the tap.
PeerInformation Contains the information of identification
ProximityMessage Represents the message received.
ConnectionRequestedEventArgs Contains the properties which are passed to the application through the event of ConnectionRequested
TriggeredConnectionStateChangedEventArgs Contains the properties which are passed to the application through the event of TriggeredConnectionStateChanged



Last edited Jul 28, 2014 at 5:22 AM by brmontei, version 5