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

谁都会走 提交于 2020-05-26 16:30:41

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/50464810/is-it-possible-to-hide-ios-system-alert-for-nfc-reading-session

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!