Post not yet marked as solved
I am trying to use apple wallet to be detected by a RFID reader, specially a PN5180 with Arduino, running ISO15693 protocol. Is there a way to have this work? I also know that this reader can run the Felica protocol and I think this is the protocol I would have to use, but want make sure that ISO15693 will not work.
Post not yet marked as solved
Is it possible to write sequentially on multiple tags using NFC?
e.g. I have 10 tags and in my app set the number of writing and pressing on a button start first writing on first tag. when wrote, start an other writting and so on....
Post not yet marked as solved
I am having a lot of trouble getting NFC to work a second time. The first time using it to read works just fine, but the second time I try it gives me errors about the delegate method not being found. The exact error is this:
[CoreNFC] 00000002 8093c3f0 -[NFCTagReaderSession didDetectTags:connectedTagIndex:]:141 Delegate does not implement -tagReaderSession:didDetectTags: method
I know that the delegate is set because it is calling the same code. I do invalidate the session after reading. I have stepped through the code and made sure that line is called.
Does anyone have any suggestions?
Post not yet marked as solved
I am using iOS 14 beta 3. I read there was an issue with this in earlier iOS 13 betas. It seems to have reappeared with iOS 14?
I create a personal automation in Shortcuts with an NFC tag. Works great the first time. Then it never reads it again. If I get an app that can read tags, it reads the tag, so I know the tag is working properly, it's just that the iPhone doesn't read it after the first time.
Anyone else have this? I did submit feedback to Apple on iOS 14.
Thanks!
Dan
Post not yet marked as solved
To read from an Mifare Ultralight tag (NTAG I2C Plus), I'm using NFCMifareTag.sendMifareCommand method. It works most of the times, but I randomly get errors of types:
Tag Response Error / Tag No Response
Tag Connection Lost
Stack error
Moreover, these errors ar eobserved way more frequently on iPhone 13 Pro max model than any other iPhones, not sure why.
This is the code block for reference:
miFareTag.SendMiFareCommand(tagCommand, completionHandler: (nsdataObj, error1) =>
{
if ((error1 == null) && (nsdataObj != null))
{
readSuccess = true;
}
else
{
readSuccess = false;
// here error1 prints Tag response error or Tag no response or Tag connection lost or Stack error
}
});
Has anyone observed these errors and knows ways to avoid them?
I could not find any documentation on any of these error types. Can someone guide me?
Post not yet marked as solved
Apple's docs for Background Tag Reading state clearly that:
...be aware there are times when the display is on and background tag reading is unavailable, such as if [...] Airplane mode is enabled.
Is anyone aware of the actual reason behind this restriction?
Consider these examples:
User A visits a different country and doesn't have local cell service. They use WiFi to access the internet, but keep airplane mode on to avoid expensive roaming charges. They apparently need to pay roaming fees in order to scan an NFC tag.
User B is actually on a plane (literally the reason for airplane mode). They strike up a conversation with their seatmate, who wants to share contact info using an NFC business card. It won't work until the flight lands.
In both of these cases, airplane mode is restricting what seem to be harmless attempts to scan a tag. Further, users don't commonly understand this restriction, and I am at a loss for how to explain Apple's reasoning to frustrated customers.
Does anyone have a good explanation they could share?
Post not yet marked as solved
I have a NFC-B card and it has several application identifiers.
I am trying to get two AIDs using an iphone. However, I only knew how to get one AID (item0 of info.plist).
I was able to get AIDs one at a time, however, I did not know how to get several AIDs at once.
Would you know how to do that?
According to an official documentation, it says that a system stores added queue. However, I don’t know how to get the queue.
NFCTagReaderSession | Apple Developer Documentation
if I can get the queue , I should be able to solve this problem.
NFCReader.swift
Post not yet marked as solved
Hi,
With the recent iOS beta release there is an announcement that tap to pay will be introduced with limited partners and then rolled out later this year. What are the criteria to participate in this program in the early stage since our current product relay on mobile based ticketing where we want to allow our customers to make fastest possible payment using iOS devices and vendors to accept the payment easiest possible way.
Post not yet marked as solved
Hi All,
We are using a ST25DV NFC tag and Fast Transfer Mode. Our iOS app sends a custom command that sends some data as an input and expects a response from the tag that includes a payload of ~4000 bytes.
We have successfully sent this command to the tag using the "NFC Tap App" on Android and received the full data response. However, on iOS (15.3.1-iPhone 12 Pro) as we loop through and get the response (256 bytes at a time), at random point during the reading of the response we get the following error:
[CoreNFC] 00000002 80050360 -[NFCTagReaderSession transceive:tagUpdate:error:]:824 Error Domain=NFCError Code=102 "Tag response error / no response" UserInfo={NSLocalizedDescription=Tag response error / no response, NSUnderlyingError=0x283c3cde0 {Error Domain=nfcd Code=29 "Tag Error" UserInfo={NSLocalizedDescription=Tag Error, NSUnderlyingError=0x283c3c1b0 {Error Domain=com.apple.nfstack Code=20 "No response from tag" UserInfo={NSLocalizedDescription=No response from tag}}}}}
We are not using ".address" flag. We have also put in delays to ensure the FTM mailbox is full, but that didn't work.
Any clues on why this is failing?
Thanks in advance.
m
Post not yet marked as solved
Anybody having trouble decoding payload as .utf8 from CoreNFC? Something odd going on.
Post not yet marked as solved
I want to create an app that will allow users to scan a NFC card of any type, and add it to apple wallet so it is digital. How would I create the source files for the pass within the app?
Post not yet marked as solved
Our function is to use CoreNFC to detect various NFC chips to obtain the unique ID in the chip. Under the iOS14.5 system, it is normal to read other cards. When reading the ID card of a Chinese mainland citizen, the unique ID obtained is empty and all 0. The details are shown in the following figure:
Since NFC reads the ID card of mainland Chinese citizens can only be used after iOS 14.5, I don't know if Apple did not open it, or what restrictions Apple has, it has been tangled for a long time.
With the same code, it is normal to read other NFC cards, as shown in the figure below:
Hope someone can help me
Post not yet marked as solved
Hi @everybody,
I'm working with NFC Tag of NXP Semiconductor: this tag is not NDEF compliant, but it is part of MIFARE Ultralight family (NFC tag type 2).
All operation, both reading and writing, works well.
I've just one question that concern the reading of multiple byte from memory: CoreNFC expose a method in order to retrieve the maximum lenght of payload that can be exchanged between Iphone and tag NFC?
I mean, is there a command equivalent to the MaxTransceiveLength (https://docs.microsoft.com/en-us/dotnet/api/android.nfc.tech.nfca.maxtransceivelength?view=xamarin-android-sdk-12) used in Android?
Here is the code used in order to read data from tag connected:
tagConnected!.sendMiFareCommand(commandPacket: command)
The command instead is made up in this way:
[3A, 00, 42]
3Ah --> Fast Read
00h --> Start byte address
42h --> End byte address
I would use the MaxTransceiveLength as maximum distance between Start byte address and End byte address.
Post not yet marked as solved
Hey everyone! While working on an app which reads the Unique Identifiers of NFC tags I ran into a problem. When I run the code the phone is able to read the tag and add the UID into an array (I checked this by making it print the array whenever the array is updated) but I am unable to make the View update. The reason this is tricky is that when you press a button on the view, it activates the reader function reader.activate() which then updates the array in the Data class only if it successfully extracted the UID. How would I make the View reload every time a new UID is added to the array? Below is the code for the content view, Data class and then the NFC reader. Thanks!
View:
struct ContentView: View {
@StateObject var data = Data()
let reader : NFCReader = NFCReader()
var body: some View {
NavigationView {
List {
Section(
header: Text("\(data.itemCount)" + " Items")
) { ForEach(data.products, id: \.self) {
product in Text(product)
}
.onDelete(perform: data.deleteItem)
.onMove(perform: data.moveItem)
}
}
.navigationTitle("My Products")
.navigationBarItems(leading: EditButton(), trailing: AddButton)
.navigationViewStyle(.stack)
}
.environmentObject(data)
}
var AddButton: some View {
Button(action: {
reader.activate()
// Next, once reader.activate() is done and sends data the tagUID, i need to open a new view with text imputs for name and description of product.
}, label: {
Image(systemName: "iphone.radiowaves.left.and.right")
})
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
// Do I need EnvironmentObject here???
.environmentObject(Data())
}
}
Data class:
//import Foundation
class Data: ObservableObject {
var tagCode = "UID"
@Published var products: [String] = []
@Published var itemCount = 0
func addItem() {
products.append(tagCode)
itemCount = itemCount + 1
print(tagCode + " Works!")
print(products)
}
func deleteItem(indexSet : IndexSet) {
products.remove(atOffsets: indexSet)
itemCount = itemCount - 1
}
func moveItem(indices : IndexSet, newOffset : Int) {
products.move(fromOffsets: indices, toOffset: newOffset)
}
}
NFC Reader:
import Foundation
import CoreNFC
import SwiftUI
class NFCReader: NSObject, ObservableObject, NFCTagReaderSessionDelegate {
var data : Data = Data()
private var tagUID = "UID"
private var session: NFCTagReaderSession?
func activate() {
self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
self.session?.alertMessage = "Hold Your Phone Near NFC Tag"
self.session?.begin()
}
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("Session Begun!")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print("Error with Launching Session")
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print("Connecting To Tag")
if tags.count > 1{
session.alertMessage = "More Than One Tag Detected, Please try again"
session.invalidate()
}
let tag = tags.first!
session.connect(to: tag) { [self] (error) in
if nil != error{
session.invalidate(errorMessage: "Connection Failed")
}
if case let .miFare(sTag) = tag{
let UID = sTag.identifier.map{ String(format: "%.2hhx", $0)}.joined()
print("UID:", UID)
print(sTag.identifier)
session.alertMessage = "UID Captured"
session.invalidate()
DispatchQueue.main.async {
self.tagUID = "\(UID)"
data.tagCode = "\(UID)"
data.addItem()
// add inputview change here
}
}
}
}
}
Post not yet marked as solved
Hey everyone! So I've been creating a program to extract the UID (unique identifier) from an NFC Tag and have been stuck on this very last problem: On the third line I created a variable which I want to be able to change called tagUID, initially just "UID". If you look down to the very last line of code, you see that (if there is a connection to the tag) the last thing it's supposed to do is change the state of tagUID to whatever the UID of the tag is, but it's refusing to do so. Everything else works great its only not changing that variable!
class NFCReader: NSObject, ObservableObject, NFCTagReaderSessionDelegate {
@State var tagUID = "UID"
var session: NFCTagReaderSession?
func activate() {
self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
self.session?.alertMessage = "Hold Your Phone Near the NFC Tag"
self.session?.begin()
}
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("Session Begun!")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print("Error with Launching Session")
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print("Connecting To Tag")
if tags.count > 1{
session.alertMessage = "More Than One Tag Detected, Please try again"
session.invalidate()
}
let tag = tags.first!
session.connect(to: tag) { [self] (error) in
if nil != error{
session.invalidate(errorMessage: "Connection Failed")
}
if case let .miFare(sTag) = tag{
let UID = sTag.identifier.map{ String(format: "%.2hhx", $0)}.joined()
print("UID:", UID)
print(sTag.identifier)
session.alertMessage = "UID Captured"
session.invalidate()
DispatchQueue.main.async {
self.tagUID = "\(UID)"
}
tagUID = "\(UID)"
}
}
}
}
First of all I'm trying to read all the memory data from NCF Iso15693 Tag (icode slix2)
I trying to call the method readMultipleBlocksWithRequestFlags of NFCISO15693Tag class.
I'm reading the NFC tag and all the data seems to be correct(indeed in Android works perfect).
I read the NFC tag in NFCTools app (https://apps.apple.com/es/app/nfc-tools/id1252962749) and I get all the data that I want to read.
I using NFCTagReaderSession
[[NFCTagReaderSession alloc]initWithPollingOption:NFCPollingISO15693 delegate:self queue:nil]
the delegate code:
id<NFCTag> currentTag = [tags firstObject];
if (currentTag.type == NFCTagTypeISO15693) {
id<NFCISO15693Tag> mytag = [currentTag asNFCISO15693Tag];
[tagSession connectToTag:currentTag completionHandler:^(NSError * _Nullable error) {
BOOL available = [currentTag isAvailable];
NFCISO15693RequestFlag requestFlag = NFCISO15693RequestFlagAddress;
[mytag readMultipleBlocksWithRequestFlags:requestFlag blockRange:NSMakeRange(0, 8) completionHandler:^(NSArray<NSData *> * _Nonnull dataBlocks, NSError * _Nullable error) {
BOOL available2 = [currentTag isAvailable];
NSLog(@"error:%@",error);
}];
}];
The Issue:
When I connect to the tag, the tag is available and is connected to the session
When I try to read the blocks, the tag is connected, but I get a NFCError Code=100 "Tag connection lost"
I spent a whole week with this issue and I'm a little bit desperate
Hey again, I recently asked about updating a variable but now have a new problem. I am creating an NFC reader which when I press scan it prints the UID (Unique Identifier) of the NFC in a text field. When the button labeled "Scan" is pressed, the function activate() runs which activates the NFC reader and updates a variable within the NFCReader class called tagUID to the UID of the NFC chip. After activate() the button then changes tagCode to equal tagUID. The problem is that I want it to update only after the NFCTagReaderSession ends, as it only updates it to the previous UID scanned right now as it did not finish scanning before I update the variable. How do I do this? The code is below:
struct ContentView: View {
let reader: NFCReader = NFCReader()
@State var tagCode = "UID"
var body: some View {
VStack{
Text(tagCode)
Button {
reader.activate()
tagCode = reader.tagUID
} label: {
Text("Scan")
.font(.title)
}.padding()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
class NFCReader: NSObject, ObservableObject, NFCTagReaderSessionDelegate {
var tagUID = "UID"
var session: NFCTagReaderSession?
func activate() {
self.session = NFCTagReaderSession(pollingOption: .iso14443, delegate: self)
self.session?.alertMessage = "Hold Your Phone Near the NFC Tag"
self.session?.begin()
}
func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
print("Session Begun!")
}
func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
print("Error with Launching Session")
}
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
print("Connecting To Tag")
if tags.count > 1{
session.alertMessage = "More Than One Tag Detected, Please try again"
session.invalidate()
}
let tag = tags.first!
session.connect(to: tag) { [self] (error) in
if nil != error{
session.invalidate(errorMessage: "Connection Failed")
}
if case let .miFare(sTag) = tag{
let UID = sTag.identifier.map{ String(format: "%.2hhx", $0)}.joined()
print("UID:", UID)
print(sTag.identifier)
session.alertMessage = "UID Captured"
session.invalidate()
DispatchQueue.main.async {
self.tagUID = "\(UID)"
}
}
}
}
}
Post not yet marked as solved
Will have iphone nfc support for card emulation
Post not yet marked as solved
It was announced in CoreNFC Video on WWDC that starting from iOS 14 sendRequestWithFlag() command is available as a "write through" interface to transceive commands directly to a tag.
There was previously a method customCommandWithRequestFlag() however this was considered to be not working when Addressed Mode (Flag Byte bit mask 0x20) is used.
I must use addressed command according to NXP SLIX2 data sheet to authenticate at the tag.
So after customCommand..() was not working for me, I tried sendRequest...() but it is also not working, returning NFCError Code=102 "Stack Error" in the case where I consider to be the proper message.
The trick at ISO15693 protocol is that after each custom command there should come a byte equal to manufacturer ID. From my experiments I saw that customCommand..() method seem to add this byte by itself. So with this approach non-addressed commands do work.
In addressed mode, the full UID should come additionally after the manufacturer ID byte. It is not clear from description of the sendRequest() method if it will add anything on its own or not. Therefore I do not know which parameter I need to add and I experimented with adding/not adding manufacturer ID and/or UID but it either returns the error above or "transceive failed".
Is it possible to make open the behaviour inside the sendRequest()?
I have a proof that the command works with this tag because the same request executed on android works immediately.
Post not yet marked as solved
Hello,I am currently writing a little prototype using CoreNFC and NFCTagReaderSession with ISO15693 tags.I have a custom command that takes some data as an input and expects to get output data from the tag.I have successfully sent this command to the tag using the app "NFC Tools" on Android and received the data that I've expected, but fail to get the same response on iOS 13.3.1. All I get is this error:[NFCTagReaderSession transceive:tagUpdate:error:]:735 Error Domain=NFCError Code=102 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x282454150 {Error Domain=nfcd Code=10 "Invalid Parameter" UserInfo={NSLocalizedDescription=Invalid Parameter}}}Why does this command work on Android but not on iOS?The command lies within the range of valid custom commands (0xA0 to 0xDF) for ISO15693 tags.Has anyone experienced similar issues? Maybe someone can share some learnings. I am grateful for every piece of information or any help.Kind regards.