You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a Mac using NativeScript CLI 8.1.4 create a new Hello World Angular project
Add app.entitlements and NFCReaderUsageDescription as instructed
Add the nativescript-nfc plugin
Place the following code into ngOnInit in item-detail.component.ts:
`
let nfc = new Nfc();
nfc.available().then(avail => {
console.log(avail ? "NFC is enabled" : "NFC is disabled");
});
nfc
.setOnNdefDiscoveredListener(
(data: NfcNdefData) => {
// data.message is an array of records, so:
if (data.message) {
for (let m in data.message) {
let record = data.message[m];
console.log(
"Ndef discovered! Message record: " + record.payloadAsString
);
}
}
},
{
// iOS-specific options
stopAfterFirstRead: true,
scanHint: "Scan a tag, baby!"
}
)
.then(() => {
console.log("OnNdefDiscovered listener added");
});
`
This code works on Android when tapping an NFC dongle (i.e. "Ndef discovered! Message record: Test" is printed to the console) but on iOS, I get:
CONSOLE LOG: NFC is enabled
CONSOLE LOG: OnNdefDiscovered listener added
iPhone nfctest(Foundation)[72883] : <NSXPCConnection: 0x282864fa0> connection to service with pid 60 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
Exception: decodeObjectForKey: class "NFFieldNotification" not loaded or does not exist
I am running iOS 15.0.2 on an iPhone 11 and I have confirmed the App has NFC Tag Reading for the App ID.
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
`
`
This code works on Android when tapping an NFC dongle (i.e. "Ndef discovered! Message record: Test" is printed to the console) but on iOS, I get:
CONSOLE LOG: NFC is enabled
CONSOLE LOG: OnNdefDiscovered listener added
iPhone nfctest(Foundation)[72883] : <NSXPCConnection: 0x282864fa0> connection to service with pid 60 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
Exception: decodeObjectForKey: class "NFFieldNotification" not loaded or does not exist
I am running iOS 15.0.2 on an iPhone 11 and I have confirmed the App has NFC Tag Reading for the App ID.
The text was updated successfully, but these errors were encountered: