Skip to main content

SDK Set Up

Before you call functions to communicate with Med-ic and eCAP smart packaging, the CertiScan Mobile SDKs must be added to your project and configured properly.

CertiScan iOS SDK

  1. Copy the CertiScanSDK.framework to the directory of your iOS project and add it to the project. Make sure “Copy items if needed” is selected.

  2. Turn on Near Field Communication Tag Reading under the Capabilities tab for the project’s target. (see Add a capability to a target and Building an NFC Tag-Reader App)

  3. Make sure CoreNFC.framework and CertiScanSDK.framework are added to the “Frameworks, Libraries, and Embedded Content” for the project’s target.

    Add Frameworks

  4. Add properties to Info of the project’s target for NFC usage.

    1. Select Info.
    2. Expand Custom iOS Target Properties.
    3. Add “Privacy - NFC Scan Usage Description” and write the description for NFC scan usage.
    4. Add “ISO7816 application identifiers for NFC Tag Reader Session” and set “D2760000850101” to the value of “Item 0”.

    Add Frameworks

Verify Your Set Up

Verify by calling the function NFCAPIManager.getSDKInfo(...). This will return the SDK information if the CertiScanSDK.framework is added to your project successfully.

import CertiScanSDK

func verification() {

NFCAPIManager.getSDKInfo
{ responseJsonString in
if let output = responseJsonString {
print("output = \(output)")
}
}

}
Console
output={
"name" : "CertiScanSDK",
"version" : "1.0",
"build" : "1"
}

CertiScan Android SDK

  1. Copy the CertiScanSDK.aar to the “libs” directory of your Android project.

  2. In build.gradle, set compileSdkVersion to the level 31 or higher. And minSdkVersion must be the level 23 or higher.

    // build.gradle (:app)

    android {
    compileSdk 31

    defaultConfig {
    minSdk 23
    targetSdk 31
    }

    }
  3. Modify “implementation fileTree” in build.gradle of the Module app as below:

    // build.gradle (:app)

    dependencies {

    // implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

    }
  4. Sync project with Gradle files (in the menu "File").

    caution

    You must sync project with Gradle files after CertiScanSDK.aar is added or replaced. Otherwise, Android Studio might not recognize it properly.

  5. Add NFC permission to AndroidManifest.xml.

    <manifest>
    <uses-permission android:name="android.permission.NFC" />
    <!-- optional-->
    <uses-feature
    android:name="android.hardware.nfc"
    android:required="true" />
    </manifest>

    Set “required” as true to the uses-feature element "android.hardware.nfc" so that your application shows up in Google Play only for devices that have NFC hardware. If your application uses NFC functionality, but that functionality is not crucial to your application, you can omit the uses-feature element and check for NFC availability at runtime by checking to see if “getDefaultAdapter()” is null.

  6. Create “filter_nfc.xml” file to “/res/xml/” directory of your project. Add the following to it.

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <tech-list>
    <tech>android.nfc.tech.IsoDep</tech>
    </tech-list>
    </resources>
  1. Add NFCReaderActivity to AndroidManifest.xml, and also configure your Activity with intent-filter and meta-data.

    <manifest>
    <application>
    <activity android:name="CertiScanSDK.NFCReaderActivity"
    android:launchMode="singleTask"
    android:theme="@style/Theme.Transparent"
    android:exported="false">
    <intent-filter>
    <action android:name="android.nfc.action.TECH_DISCOVERED" />
    </intent-filter>
    <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
    android:resource="@xml/filter_nfc" />
    </activity>
    <activity android:name="your Activity"
    android:exported="true">
    <intent-filter>
    <action android:name="android.nfc.action.TECH_DISCOVERED" />
    </intent-filter>
    <meta-data
    android:name="android.nfc.action.TECH_DISCOVERED"
    android:resource="@xml/filter_nfc" />
    </activity>
    </application>
    </manifest>

    If your app targets Android 12 and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

Verify Your Set Up

Verify by calling the method NFCAPIManager.getSDKInfo(...). This will return the SDK information if the CertiScanSDK.aar is added to your project successfully.

import CertiScanSDK.NFCAPIManager
import CertiScanSDK.NFCReaderStatus

fun verification() {

val callback = object : NFCAPIManager.Callback {
override fun OnComplete(responseJsonString: String?) {
Log.i("CertiScan", "output=$responseJsonString")
}

override fun onNFCReaderStatusChanged(status: NFCReaderStatus?) {
}
}

NFCAPIManager.getSDKInfo(callback)

}
Console
output={
"name" : "CertiScanSDK",
"version" : "1.0",
"build" : "1"
}