async void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { if (!CrossNFC.Current.IsWritingTagSupported) { await ShowAlert("Writing tag is not supported on this device"); return; } try { var record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Hi Buddy!") //TypeFormat = NFCNdefTypeFormat.Uri, //Payload = NFCUtils.EncodeToByteArray("http://google.fr") }; tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo); } } catch (System.Exception ex) { await ShowAlert(ex.Message); } }
void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { try { if (!CrossNFC.Current.IsWritingTagSupported) { return; } try { NFCNdefRecord record = null; switch (_type) { case NFCNdefTypeFormat.WellKnown: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.WellKnown, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; case NFCNdefTypeFormat.Uri: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Uri, Payload = NFCUtils.EncodeToByteArray("https://github.com/franckbour/Plugin.NFC") }; break; case NFCNdefTypeFormat.Mime: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; default: break; } if (!format && record == null) { throw new Exception("Record can't be null."); } tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo, _makeReadOnly); } } catch (System.Exception ex) { } } catch (Exception ex) { } }
async void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { try { if (!CrossNFC.Current.IsWritingTagSupported) { await DisplayAlert("Alert", "Writing tag not supported on this device", "Ok"); return; } try { NFCNdefRecord record = null; switch (_type) { case NFCNdefTypeFormat.WellKnown: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.WellKnown, MimeType = MonthlyPassCashPaymentPage.MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; case NFCNdefTypeFormat.Uri: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Uri, Payload = NFCUtils.EncodeToByteArray("https://github.com/franckbour/Plugin.NFC") }; break; case NFCNdefTypeFormat.Mime: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MonthlyPassCashPaymentPage.MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; default: break; } if (!format && record == null) { throw new Exception("Record can't be null."); } tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo, _makeReadOnly); } } catch (System.Exception ex) { await DisplayAlert("Alert", ex.Message, "Ok"); } } catch (Exception ex) { await DisplayAlert("Alert", "Unable to proceed,Please contact Admin" + ex.Message, "Ok"); } }
async void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { if (!CrossNFC.Current.IsWritingTagSupported) { await ShowAlert("Writing tag is not supported on this device"); return; } try { NFCNdefRecord record = null; switch (_type) { case NFCNdefTypeFormat.WellKnown: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.WellKnown, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("This is a text message!") }; break; case NFCNdefTypeFormat.Uri: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Uri, Payload = NFCUtils.EncodeToByteArray("https://google.fr") }; break; case NFCNdefTypeFormat.Mime: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("This is a custom record!") }; break; default: break; } if (!format && record == null) { throw new Exception("Record can't be null."); } tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo); } } catch (System.Exception ex) { await ShowAlert(ex.Message); } }
void Current_OnTagDiscovered(ITagInfo tagInfo, bool format) { try { if (!CrossNFC.Current.IsWritingTagSupported) { DisplayAlert("Alert", "Writing tag not supported on this device", "Ok"); return; } try { NFCNdefRecord record = null; switch (_type) { case NFCNdefTypeFormat.WellKnown: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.WellKnown, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; case NFCNdefTypeFormat.Uri: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Uri, Payload = NFCUtils.EncodeToByteArray("https://github.com/franckbour/Plugin.NFC") }; break; case NFCNdefTypeFormat.Mime: record = new NFCNdefRecord { TypeFormat = NFCNdefTypeFormat.Mime, MimeType = MIME_TYPE, Payload = NFCUtils.EncodeToByteArray("Plugin.NFC is awesome!") }; break; default: break; } if (!format && record == null) { throw new Exception("Record can't be null."); } tagInfo.Records = new[] { record }; if (format) { CrossNFC.Current.ClearMessage(tagInfo); } else { CrossNFC.Current.PublishMessage(tagInfo, _makeReadOnly); } } catch (System.Exception ex) { DisplayAlert("Alert", ex.Message, "Ok"); } } catch (Exception ex) { DisplayAlert("Alert", "Unable to proceed,Please contact Admin" + ex.Message, "Ok"); dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "MasterDetailHomePage.xaml.cs", "", "Current_OnTagDiscovered"); } }