Welcome to our new developer portal! Use the "Ask" button to chat with our AI Agent.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

3. Manage NFCPresentmentIntentAssertion

The NFCPresentmentIntentAssertion object is used to block the default payment application from receiving the "double-click" or "field detect" event. Therefore, for non-default payment applications, it is required to use the NFCPresentmentIntentAssertion object in order to perform the contactless payment.

Since iOS 18, you are required to use presentment intent assertion in order to receive the event ContactlessPaymentSession.Event.posConnected from TSH Pay SDK, which is based on the CardSession.Event.ReaderDetected event. If you do not use the presentment intent assertion, the event that your application received will be NFCWindowSceneEvent.readerDetected in SceneDelegate.

When using the NFCPresentmentIntentAssertion object, it is important to manage its lifecycle properly.

  • The validity of NFCPresentmentIntentAssertion object must be maintained while displaying NFC content, and relying on a local variable that is deallocated upon exiting the function may result in unexpected behavior.

  • The presentment intent assertion expires after 15 seconds and after it expires, there is a 15-second cool-down period before you can acquire a new instance. To ensure proper integration with NFCPresentmentIntentAssertion, you should use it as a global object in order to maintain a isValid check to reuse the existing one.

The following code snippet demonstrates how to use the NFCPresentmentIntentAssertion object:

import CoreNFC

@available(iOS 17.4, *)
class PresentmentIntentWrapper {
    
    static var presentmentIntent: NFCPresentmentIntentAssertion?
    
    static func acquire() async throws {
        presentmentIntent = try await NFCPresentmentIntentAssertion.acquire()
    }
    
    static func isValid() -> Bool {
        guard let presentmentIntent else {
            return false
        }
        return presentmentIntent.isValid
    }
}

For more information, refer to NFCPresentmentIntentAssertion.

Last updated

Was this helpful?