private void PublishMessageButton_Click(object sender, RoutedEventArgs e) { if (proximityDevice == null) { proximityDevice = ProximityDevice.GetDefault(); } // Make sure NFC is supported if (proximityDevice != null) { // Stop publishing the current message. if (publishedMessageId != -1) { proximityDevice.StopPublishingMessage(publishedMessageId); } // Publish the new one publishedMessageId = proximityDevice.PublishMessage("Windows.JumpstartMessageType", MessageTextBox.Text, new MessageTransmittedHandler((s, args) => Dispatcher.BeginInvoke(() => MessageBox.Show("Message transmitted!"))) ); } }
void ProximityDevice_PublishMessage(object sender, RoutedEventArgs e) { if (_publishedMessageId == -1) { rootPage.NotifyUser("", NotifyType.ErrorMessage); String publishText = ProximityDevice_PublishMessageText.Text; ProximityDevice_PublishMessageText.Text = ""; // clear the input after publishing. if (publishText.Length > 0) { _publishedMessageId = _proximityDevice.PublishMessage("Windows.SampleMessageType", publishText); rootPage.NotifyUser("Message published, tap another device to transmit.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Please type a message", NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("This sample only supports publishing one message at a time.", NotifyType.ErrorMessage); } }
private async void btnPayForServices_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { NFCutility = ProximityDevice.GetDefault(); if (NFCutility != null) { string HardwareID = GetDeviceID(); publishedMessageId = NFCutility.PublishMessage("Windows.SampleMessage", HardwareID.ToString(), MessageWrittenHandler); txtStatus.Text = "Touch Your Mobile with Qpay box ..."; } else { MessageDialog msgbox = new MessageDialog("Please, Enable NFC!"); await msgbox.ShowAsync(); } }