NFC

Improve this doc

$ ionic plugin add phonegap-nfc

Repo: https://github.com/chariotsolutions/phonegap-nfc

The NFC plugin allows you to read and write NFC tags. You can also beam to, and receive from, other NFC enabled devices.

Use to

This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty between NFC devices, tag types, and operating systems.

Usage

import {NFC, Ndef} from 'ionic-native';

let message = Ndef.textRecord('Hello world');
NFC.share([message]).then(onSuccess).catch(onError);

Static Members

addNdefListener(onSuccess, onFailure)

Registers an event listener for any NDEF tag.

Param Type Details
onSuccess
onFailure

Returns: Observable<any>

addTagDiscoveredListener(onSuccess, onFailure)

Registers an event listener for tags matching any tag type.

Param Type Details
onSuccess
onFailure

Returns: Observable<any>

addMimeTypeListener(mimeType, onSuccess, onFailure)

Registers an event listener for NDEF tags matching a specified MIME type.

Param Type Details
mimeType
onSuccess
onFailure

Returns: Observable<any>

addNdefFormatableListener(onSuccess, onFailure)

Registers an event listener for formatable NDEF tags.

Param Type Details
onSuccess
onFailure

Returns: Observable<any>

write(message)

Qrites an NdefMessage to a NFC tag.

Param Type Details
message any[]

Returns: Promise<any>

makeReadyOnly()

Makes a NFC tag read only. Warning this is permanent.

Returns: Promise<any>

share(message)

Shares an NDEF Message via peer-to-peer.

Param Type Details
message

An array of NDEF Records.

Returns: Promise<any>

unshare()

Stop sharing NDEF data via peer-to-peer.

Returns: Promise<any>

erase()

Erase a NDEF tag

handover(uris)

Send a file to another device via NFC handover.

Param Type Details
uris

A URI as a String, or an array of URIs.

Returns: Promise<any>

stopHandover()

Stop sharing NDEF data via NFC handover.

Returns: Promise<any>

showSettings()

Show the NFC settings on the device.

Returns: Promise<any>

enabled()

Check if NFC is available and enabled on this device.

Returns: Promise<any>

bytesToString(bytes)

Convert bytes to string

Param Type Details
bytes number[]

Returns: string

stringToBytes(str)

Convert string to bytes

Param Type Details
str string

Returns: number[]

bytesToHexString(bytes)

Convert bytes to hex string

Param Type Details
bytes number[]

Returns: string

API

Native

General