示例#1
0
        private void MessageReceived(ProximityDevice sender, ProximityMessage message)
        {
            NdefMessage ndefMessage = new NdefMessage();

            ndefMessage.AddRecord(new NdefRecord
            {
                Data       = message.Data.ToArray(),
                RecordType = message.MessageType
            });
        }
示例#2
0
            public override void DidDetect(NFCNdefReaderSession session, NFCNdefMessage[] messages)
            {
                foreach (var message in messages)
                {
                    NdefMessage newMessage = new NdefMessage();
                    foreach (var record in message.Records)
                    {
                        var parsedRecord = ParseNdefRecord(record);
                        newMessage.AddRecord(parsedRecord);
                    }

                    reader.Reading?.Invoke(this, newMessage);
                }
            }
示例#3
0
 private void Reader_Reading(object sender, InTheHand.Nfc.NdefMessage e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         foreach (var record in e.Records)
         {
             if (record.RecordType == NdefRecordType.Mime)
             {
                 DisplayAlert("NDEF", $"{record.MediaType} {((byte[])record.Data).Length}", "OK");
             }
             else
             {
                 DisplayAlert("NDEF", $"{record.RecordType} {record.Data}", "OK");
             }
         }
     });
 }