Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide iOS system alert for NFC reading session

Tags:

ios

nfc

core-nfc

When you successfully finish an NFC reading session you'll see something like that:

Successfully finished NFC session

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)?

like image 605
Legonaftik Avatar asked May 22 '18 09:05

Legonaftik


People also ask

How do I view NFC data on iPhone?

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.

Do iPhones read NFC tags automatically?

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.

Can iPhone read NFC contacts?

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.


1 Answers

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.

like image 149
Legonaftik Avatar answered Oct 04 '22 20:10

Legonaftik