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. NFCPresentmentIntentAssertion を管理する

この NFCPresentmentIntentAssertion オブジェクトは、既定の支払いアプリケーションが「ダブルクリック」または「フィールド検出」イベントを受信するのをブロックするために使用されます。したがって、既定以外の支払いアプリケーションでは、 NFCPresentmentIntentAssertion 非接触決済を行うために、オブジェクトを使用する必要があります。

iOS 18以降、イベントを受信するには presentment intent assertion を使用する必要があります ContactlessPaymentSession.Event.posConnected TSH Pay SDK からのもので、これは次の CardSession.Event.ReaderDetected イベントです。presentment intent assertion を使用しない場合、アプリケーションが受信するイベントは NFCWindowSceneEvent.readerDetectedSceneDelegate.

次の NFCPresentmentIntentAssertion オブジェクトを使用する場合、そのライフサイクルを適切に管理することが重要です。

  • 次の有効性は NFCPresentmentIntentAssertion オブジェクトは NFC コンテンツを表示している間、維持する必要があり、関数を抜けると解放されるローカル変数に依存すると、予期しない動作につながる可能性があります。

  • presentment intent assertion は15秒後に期限切れとなり、期限切れ後は新しいインスタンスを取得するまで15秒のクールダウン期間があります。〜との適切な統合を確実にするには NFCPresentmentIntentAssertion、有効性を維持するために、グローバルオブジェクトとして使用する必要があります isValid 既存のものを再利用するための確認です。

以下のコードスニペットは、次の 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.

最終更新

役に立ちましたか?