New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

capacitor-hce-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-hce-plugin

Plugin to make your capacitor app to support NFC HCE

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
207
decreased by-14.11%
Maintainers
1
Weekly downloads
 
Created
Source

Capacitor HCE plugin

Host Card Emulation (HCE) Plugin for Capacitor / Ionic on Android. This project is ported and reuse code based from https://github.com/agmo-ios-team/flutter_nfc_hce that forked for Flutter HCE Plugin https://pub.dev/packages/flutter_nfc_hce you can follow the introcuction for thier project

Install

npm install capacitor-hce-plugin
npx cap sync

Limitation

  • This plugin only support for Android iOS is open to contribution
  • This plugin only support NFC Type-4 Tag with NDEF message for now

Android Setup

  1. Add permission to your AndroidManifest.xml.

     <uses-permission android:name="android.permission.NFC" />
     <uses-feature android:name="android.hardware.nfc" android:required="true" />
     <uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
     <uses-permission android:name="android.permission.VIBRATE" />
    
  2. Register service to your AndroidManifest.xml.

     <service android:name="com.thanmgan22.plugins.nfchce.KHostApduService"
                  android:exported="true"
                  android:enabled="true"
                  android:permission="android.permission.BIND_NFC_SERVICE">
        <intent-filter>
            <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
       <meta-data android:name="android.nfc.cardemulation.host_apdu_service"
                  android:resource="@xml/apduservice"/>
     </service>
    
  3. Add apduservice.xml to your res/xml

    <?xml version="1.0" encoding="utf-8"?>
    <host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
                       android:description="@string/servicedesc" android:requireDeviceScreenOn="false" android:requireDeviceUnlock="false">
        <aid-group android:description="@string/aiddescription"  android:category="other" >
            <aid-filter android:name="D2760000850101"/>
        </aid-group>
    </host-apdu-service>
    
  4. Add strings.xml to your res/values

    <resources>
    <string name="servicedesc">servicedesc</string>
    <string name="aiddescription">aiddescription</string>
    </resources>
    

API

startNfcHce(...)

startNfcHce(options: { content: string; mimeType?: string; persistMessage?: boolean; }) => Promise<{ success: boolean; }>
ParamType
options{ content: string; mimeType?: string; persistMessage?: boolean; }

Returns: Promise<{ success: boolean; }>


stopNfcHce()

stopNfcHce() => Promise<{ success: boolean; }>

Returns: Promise<{ success: boolean; }>


isNfcSupported()

isNfcSupported() => Promise<{ supported: boolean; }>

Returns: Promise<{ supported: boolean; }>


isNfcEnabled()

isNfcEnabled() => Promise<{ enabled: boolean; }>

Returns: Promise<{ enabled: boolean; }>


isNfcHceSupported()

isNfcHceSupported() => Promise<{ supported: boolean; }>

Returns: Promise<{ supported: boolean; }>


isSecureNfcEnabled()

isSecureNfcEnabled() => Promise<{ enabled: boolean; }>

Returns: Promise<{ enabled: boolean; }>


enableApduService(...)

enableApduService(options: { enable: boolean; }) => Promise<{ enabled: boolean; }>
ParamType
options{ enable: boolean; }

Returns: Promise<{ enabled: boolean; }>


addListener('onStatusChanged', ...)

addListener(eventName: 'onStatusChanged', listenerFunc: (response: { eventName: ReaderStatusType; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
ParamType
eventName'onStatusChanged'
listenerFunc(response: { eventName: ReaderStatusType; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle
PropType
remove() => Promise<void>

Enums

ReaderStatusType
MembersValue
CardEmulatorStarted'card-emulator-started'
ScanError'scan-error'
ScanCompleted'scan-completed'
CardEmulatorStopped'card-emulator-stopped'

Keywords

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc