3. NFCPresentmentIntentAssertion を管理する
この NFCPresentmentIntentAssertion オブジェクトは、既定の支払いアプリケーションが「ダブルクリック」または「フィールド検出」イベントを受信するのをブロックするために使用されます。したがって、既定以外の支払いアプリケーションでは、 NFCPresentmentIntentAssertion 非接触決済を行うために、オブジェクトを使用する必要があります。
iOS 18以降、イベントを受信するには presentment intent assertion を使用する必要があります ContactlessPaymentSession.Event.posConnected TSH Pay SDK からのもので、これは次の CardSession.Event.ReaderDetected イベントです。presentment intent assertion を使用しない場合、アプリケーションが受信するイベントは NFCWindowSceneEvent.readerDetected で SceneDelegate.
以下のコードスニペットは、次の NFCPresentmentIntentAssertion オブジェクトの使用方法を示しています:
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
}
}詳細については、 NFCPresentmentIntentAssertion.
最終更新
役に立ちましたか?