NFC

NFC

This document explains what you need to open a door via NFC.

Extend SmartCardService

First you need to extend SmartCardService from Sensorberg SDK.

internal class YourSmartCardService : SmartCardService()

Set Permission and declare Service

In your AndroidManifest.xml you have to enable NFC permission:

<uses-permission android:name="android.permission.NFC" />

and you have to declare the service:

<service
       android:name="<LOCATION_OF_YourSmartCardService>"
       android:exported="true"
       android:permission="android.permission.BIND_NFC_SERVICE">
              <intent-filter>
                     <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
              </intent-filter>
              <meta-data
                     android:name="android.nfc.cardemulation.host_apdu_service"
                     android:resource="@xml/apduservice" />
</service>

Declare AID service

You also need to specify a xml resource apduservice.xml and define the aid-filter:

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
	android:description="<PLACE_DESCRIPTION_HERE>"
	android:requireDeviceUnlock="false">
	<aid-group
              android:category="other"
		android:description="<PLACE_DESCRIPTION_HERE>">
		<aid-filter android:name="<PLACE_AID_HERE>" />
	</aid-group>
</host-apdu-service>

The aid-filter is a String you will get from Sensorberg. It allows the gateway to identify the service on the phone.