DyScan
  • DyScan Integration Guide
  • iOS Integration Guide
  • Android Integration Guide
  • Android NFC Integration Guide
  • React Native Integration Guide
  • Cordova Integration Guide
  • Integrity Verification
  • Migrating from card.io
    • Migrating from card.io (iOS)
    • Migrating from card.io (Android)
  • Integrating with Stripe
    • Integrating with Stripe (iOS)
    • Integrating with Stripe (Android)
  • Alternate Ways to Integrate iOS
    • Integrating with Swift Package Manager
    • Integrating with Carthage
    • Integrating as a Framework
  • Alternate Ways To Integrate Android
    • Manually Importing the Library
    • Using DyScanView
  • MIGRATING FROM 1.0.X TO 1.1.X
    • Migrating from 1.0.x to 1.1.x (iOS)
    • Migrating from 1.0.x to 1.1.x (Android)
    • Migrating from 1.0.x to 1.1.x (React Native)
Powered by GitBook
On this page
  • Add the Dyneti Maven repository to your project
  • Add the Dyneti and NFC library dependencies
  • Initialize DyScan
  • Check if the device supports NFC scanning
  • Enable and Disable NFC scanning in your activity
  • Read the result of the NFC Scan

Was this helpful?

Android NFC Integration Guide

PreviousAndroid Integration GuideNextReact Native Integration Guide

Last updated 5 days ago

Was this helpful?

Add the Dyneti Maven repository to your project

In your project-level build.gradle add the Dyneti Maven repository (credentials provided during integration):

allprojects {
    repositories {
        // Other repositories are here
        maven {
            credentials  {
                username = "nexusUsername"
                password = "nexusPassword"
            }
            url "https://nexus.dyneti.com/repository/maven-releases/"
            authentication {
                basic(BasicAuthentication)
            }
        }
    }
}

If you would rather integrate without using our Nexus repository, see .

Add the Dyneti and NFC library dependencies

Include both the DyScan SDK and the NFC SDK. Both should be the same version, e.g. 1.7.18 or greater.

implementation("com.dyneti.android.dyscan:dyscan-fraud:${dyscanVersion}")
implementation("com.dyneti.android.nfc:dyneti-nfc:${dyscanVersion}")

Initialize DyScan

In your Application class add the following line to initialize DyScan.

public class DyScanApplication extends Application {

  //...

  @Override
  public void onCreate() {
    super.onCreate();
    //...
    DyScan.init(this, "{YOUR_API_KEY}");
    //...
  }
}

Check if the device supports NFC scanning

You can use the method DyScan.hasNfcFeature() to confirm that the device your app is running on is able to scan cards using NFC. It will return true if the device is supported and dynetiNFC has loaded. It will return false if the device is not supported or the NFC SDK could not be found.

Enable and Disable NFC scanning in your activity

In the activity you would like to perform the scan, enable the scanner during your onResume method and disable the scanner in your onPause method.

    override fun onResume() {
        super.onResume()
        if (DyScan.hasNfcFeature()) {
            DyScan.dynetiNFC.enableScanning(this);
        }
    }

    override fun onPause() {
        if (DyScan.hasNfcFeature()) {
            DyScan.dynetiNFC.disableScanning(this);
        }
        super.onPause()
    }

Read the result of the NFC Scan

In your activity, listen for the result intent using the onNewIntent method:

override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        if (DyScan.hasNfcFeature()) {
            DyScan.dynetiNFC.handleIntent(
                intent,
                { result: com.dyneti.shared_interfaces.DynetiNFCCard ->
                    val card = result
                    runOnUiThread {
                        findViewById<TextView>(R.id.cardNumber).setText(card.cardNumber);
                        findViewById<TextView>(R.id.expirationMonth).setText(card.expirationMonth);
                        findViewById<TextView>(R.id.expirationYear).setText(card.expirationYear);
                        findViewById<TextView>(R.id.errorText).setText("")
                    }
                },
                { error: String? ->
                    Log.d("NFC", "error: $error")
                    runOnUiThread {
                        findViewById<TextView>(R.id.errorText).setText(error)
                    }
                })
        }
    }
Manually Importing the Library