Hello,
(I apologize for my poor English.)
I’m developing an iPhone application that uses NFC, but it’s not working as expected. I would appreciate your help in resolving the issue.
This app uses Core NFC API and is designed to write the URL of my blog onto the NFC tag of another smartphone and automatically open the browser. This app is installed on my iPhone but is not uploaded to the App Store.
In this app, I have implemented the following functions using the NFCNDEFReaderSessionDelegate:
(1). readerSessionDidBecomeActive
(2). readerSession(didInvalidateWithError)
(3). readerSession(didDetectNDEFs)
(4). readerSession(didDetect)
When I run this app, I can confirm that the (1) function is called, but when I bring another smartphone close to my iPhone, the (4) function, which should be triggered, does not execute. Also, (3) does not execute either.
How can I ensure that the fourth(4) function is executed?
For reference, the iOS versions of the iPhones are as follows:
・My iPhone:
iPhone 14, iOS 17.5.1
・The other iPhone:
iPhone 14, iOS 17.5.1 and iPhone se2, iOS 17.3.1
・XCode 15.4
・Program language Swift
If I understand your use case correctly, with your "Write" function you are trying to have your app become an NDEF tag. In other words you are trying to emulate an NDEF tag.
Unfortunately, this is not possible. As the name suggests a readerSession is just that. It can read NFC tags.
I believe you may have misunderstood the use case for writing to an NDEF tag. While it is possible to use the writeNDEF(_:completionHandler:) to write to an NDEF tag, that is all this function can do - write a payload to an existing NDEF tag. This function does not turn your app into an NDEF tag.
What you are trying to do is called Host Card Emulation, and this is only available for apps that fit specific requirements.
You can read the rules and requirements at HCE-based contactless transactions for apps in the European Economic Area (EEA) and follow the steps in the documentation to apply if, and only if your conditions and use case matches the stated requirements.
Argun Tekant / DTS Engineer / Core Technologies