seekerpay_nfc 1.1.0 copy "seekerpay_nfc: ^1.1.0" to clipboard
seekerpay_nfc: ^1.1.0 copied to clipboard

Seeker-native NFC tap-to-pay for SeekerPay.

seekerpay_nfc #

License: MIT

NFC tap-to-pay for the SeekerPay SDK. Writes Solana Pay URLs to NFC tags and reads them from tags or other devices using NDEF records via a native Android/iOS platform channel.


Features #

  • Write payment tags — Write a solana: Solana Pay URL to any writable NFC tag.
  • Read payment requests — Start a continuous NFC session and receive Solana Pay URLs as they are scanned.
  • Availability check — Detect whether the device supports NFC before prompting the user.
  • Settings deep-link — Open the device NFC settings screen directly.

Installation #

dependencies:
  seekerpay_nfc:
    path: ../packages/seekerpay_nfc

Android setup #

Ensure the following permission is in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />

Usage #

Check availability #

import 'package:seekerpay_nfc/seekerpay_nfc.dart';

final nfc = NfcHandler();
final available = await nfc.isAvailable();
if (!available) {
  // Show a "NFC not supported" message or open settings
  await nfc.openSettings();
}

Read NFC tags (continuous) #

await nfc.startReading(
  onTagRead: (String solanaPayUrl) {
    print('Received: $solanaPayUrl');
    // Parse it with SolanaPayUrl.decode(solanaPayUrl)
    nfc.stopReading(); // stop after first tag if desired
  },
);

Write a payment tag #

import 'package:seekerpay_qr/seekerpay_qr.dart';
import 'package:seekerpay_core/seekerpay_core.dart';

final url = SolanaPayUrl(
  recipient: myWalletAddress,
  amount: BigInt.from(1_000_000), // 1.00 SKR
  splToken: SKRToken.mintAddress,
  label: 'Pay me 1 SKR',
).encode();

await nfc.writeNdefTag(
  solanaPayUrl: url,
  onTagWritten: () => print('Tag written successfully'),
  onTagWriteError: (e) => print('Write failed: $e'),
);

Riverpod provider #

// Access the singleton NfcHandler
final nfc = ref.read(nfcHandlerProvider);

NfcHandler API #

Method Description
isAvailable() Returns true if the device has NFC hardware
startReading({onTagRead}) Begin scanning; callback fires for each scanned tag
stopReading() Stop the active NFC scan session
writePaymentTag(url) Write a Solana Pay URL to a tag (fire-and-forget)
writeNdefTag({url, onTagWritten, onTagWriteError}) Write with completion/error callbacks
openSettings() Open device NFC settings

License #

MIT — see LICENSE.