I'm able to write to a tag more than once without separating it from the phone and tapping it again. See following code for example:
ProximityDevice device = ProximityDevice.GetDefault();
device.SubscribeForMessage("WriteableTag", WriteableTagHandler);
private void WriteableTagHandler(ProximityDevice sender, ProximityMessage message)
{
var message1= Encoding.Unicode.GetBytes("http://1stUrl.com");
var message2 = Encoding.Unicode.GetBytes("http://secondUrl.com");
sender.PublishBinaryMessage("WindowsUri:WriteTag", message1.AsBuffer(), (s, e) =>
{
s.StopPublishingMessage(e);
sender.PublishBinaryMessage("WindowsUri:WriteTag", message2.AsBuffer(), (se,r)=>
{
se.StopPublishingMessage(r);
});
});
}
EDIT:
I have just checked with two devices, and in fact, it is possible to write-read more than once without separating and tapping the phones again. See the example below, where one device sends 5 messages and the other receives all of them:
Device 1 (sender):
ProximityDevice device = ProximityDevice.GetDefault();
device.DeviceArrived += (e) =>
{
for (int i = 1; i <= 5; i++)
{
e.PublishMessage("Windows.mySubType", "message " + i.ToString(), (s, m) =>
{
s.StopPublishingMessage(m);
});
}
};
Device 2 (receiver):
ProximityDevice device = ProximityDevice.GetDefault();
device.SubscribeForMessage("Windows.mySubType", (s, e) =>
{
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(e.DataAsString);
});
});