When you successfully finish an NFC
reading session you'll see something like that:
This will overlay the currently presented ViewController
for about 3 seconds. The fun part is that this behaviour is inconsistent since this window will disappear immediately if the reading session finish very fast.
It means that I cannot be sure about how long will this overlay stay for sure which is bad for our app's UX design.
The question is simple: is there a way to force this overlay to disappear or at least to handle the event of when it disappears (not when the NFC
session if finished)?
Run the sample app on your iPhone. Tap the Scan button to start scanning for tags, then hold the phone near an NFC tag. To read a tag, the sample app creates an NFC NDEF reader session and provides a delegate.
On iPhones that support background tag reading, the system scans for and reads NFC data without requiring users to scan tags using an app. The system displays a pop-up notification each time it reads a new tag. After the user taps the notification, the system delivers the tag data to the appropriate app.
Question: Q: NFC VCards on iPhones Answer: A: You would need an app to write them and an app to read them. They are available in the App Store for iPhone.
I've found an interesting way to hide that window. 2 simple steps are required:
1) When initialising your reader session set the last parameter to false: NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: false)
2) In the body of readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage])
your should call session.invalidate()
.
That's it. It will work as if you tapped Cancel/Done - the system window will disappear immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With