npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-hce-plugin

v1.0.1

Published

Plugin to make your capacitor app to support NFC HCE

Downloads

11

Readme

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; }>

| Param | Type | | ------------- | ------------------------------------------------------------------------------ | | 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; }>

| Param | Type | | ------------- | --------------------------------- | | options | { enable: boolean; } |

Returns: Promise<{ enabled: boolean; }>


addListener('onStatusChanged', ...)

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

| Param | Type | | ------------------ | ---------------------------------------------------------------------------------------------------- | | eventName | 'onStatusChanged' | | listenerFunc | (response: { eventName: ReaderStatusType; }) => void |

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

Enums

ReaderStatusType

| Members | Value | | ------------------------- | ------------------------------------ | | CardEmulatorStarted | 'card-emulator-started' | | ScanError | 'scan-error' | | ScanCompleted | 'scan-completed' | | CardEmulatorStopped | 'card-emulator-stopped' |